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

时间:2014-07-21 06:51:53

标签: java html mysql jsp

我在jsp中使用Mysql数据库来从数据库请求数据。但我收到错误,指出在第21行处理JSP页面/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>

1 个答案:

答案 0 :(得分:-1)

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