Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在第21行处理JSP页面/Home.JSP时发生Http 500错误异常_Java_Html_Mysql_Jsp - Fatal编程技术网

Java 在第21行处理JSP页面/Home.JSP时发生Http 500错误异常

Java 在第21行处理JSP页面/Home.JSP时发生Http 500错误异常,java,html,mysql,jsp,Java,Html,Mysql,Jsp,我在jsp中使用Mysql数据库从数据库请求数据。但我收到了一个错误,说明在第21行处理JSP page/Home.JSP时发生了HTTP 500错误异常 你能帮我解决这个错误吗 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> <!DOCTYPE h

我在jsp中使用Mysql数据库从数据库请求数据。但我收到了一个错误,说明在第21行处理JSP page/Home.JSP时发生了HTTP 500错误异常

你能帮我解决这个错误吗

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Home</title>
  </head>
  <body>
<%
Connection con= null;
PreparedStatement ps = null;
ResultSet rs = null;

String sql = "select Category from e_createuser";

try {
  Class.forName("com.mysql.jdbc.Driver");
  con =(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/newapplication","root","root");
  ps = (PreparedStatement)con.prepareStatement(sql);
  rs = ps.executeQuery(); 
%>
    <form method="post" action="Login.jsp">
      <center><h2 style="color:Blue"></h2>Welcome HR</center>
      <table border="1" align="center">
        <tr>
          <td>Enter Your Name :</td>
          <td><input type="text" name="name"/></td>
        </tr>
        <tr>
          <td>Enter Your Password :</td>
          <td><input type="password" name="password"/></td>
        </tr>
        <tr>
          <td>Select Category :</td>
          <td>
            <select name="Category">
              <option value="select">select</option>
<%
  while(rs.next())
  {
    String cattype = rs.getString("Category");
%>
              <option value=<%=cattype%>><%=cattype%></option>
<% 
  }
}
catch(SQLException sqe)
{
  out.println("Home"+sqe);
}
%>
            </select>
          </td>
        </tr>
        <tr>
          <td></td>
          <td><input type="submit" value="submit"/></td>
      </table>
    </form>
  </body>
</html>

家
欢迎人力资源部
输入您的姓名:
输入您的密码:
选择类别:
选择

我认为Http 500错误是内部错误,因此请检查您的数据库连接。可能您的数据库未启动也会遇到相同类型的问题。

发布完整的堆栈跟踪如果日志中没有堆栈跟踪,请尝试将
更改为out.println(“主页”+sqe)
sqe.printStackTrace()并重试。这不是正确的答案,因为HTTP错误500是一个HTTP代码,这意味着在处理服务器端脚本时出错。每个浏览器都有一个配置来显示它或直接从服务器显示错误。请参见此处的错误代码: