简体   繁体   English

HTTP 状态 500 – 内部服务器错误-JSP-Tomcat 服务器

[英]HTTP Status 500 – Internal Server Error-JSP-Tomcat server

As a beginner to Jsp, I'm building a simple web application that register/login users.作为 Jsp 的初学者,我正在构建一个简单的 Web 应用程序来注册/登录用户。 When i run the below code i'm getting the following error HTTP Status 500 - Internal Server Error Building web application in eclipse and web server is tomcat.当我运行以下代码时,我收到以下错误 HTTP 状态 500 - 在 eclipse 中构建 Web 应用程序的内部服务器错误,而 Web 服务器是 tomcat。 I've also downloaded and added the jar file.我还下载并添加了 jar 文件。 Don't know what went wrong and couldn't find any helpful answer on google as yet.不知道出了什么问题,目前在谷歌上找不到任何有用的答案。 i'm getting the same error for both the JSP(one for login and another for register)files in my project.我的项目中的 JSP(一个用于登录,另一个用于注册)文件都出现相同的错误。

register.jsp file: register.jsp 文件:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!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>Insert title here</title>
</head>
<body>

<%@ page import ="java.sql.*" %>
<%@ page import ="javax.sql.*" %>
<%
    String user=request.getParameter("userid");
    session.putValue("userid",user);
    String pass=request.getParameter("pass");
    String fname=request.getParameter("fname");
    String lname=request.getParameter("lname");
    String email=request.getParameter("email");
    Class.forName("com.mysql.jdbc.Driver");
    java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pms","root","root");
    Statement st=con.createStatement();
    ResultSet rs;
    int i= st.executeUpdate("insert into users values("+user+","+pass+","+fname+","+lname+","+email+")");

    out.println("Registered");

%>

<a href="Login.html">Login</a></br>
<a href="Comp.html">Home</a></br>

</body>
</html>

error:错误:

HTTP Status 500 – Internal Server Error


Type Exception Report

Message An exception occurred processing [/register.jsp] at line [19]

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception
org.apache.jasper.JasperException: An exception occurred processing [/register.jsp] at line [19]

16:     String fname=request.getParameter("fname");
17:     String lname=request.getParameter("lname");
18:     String email=request.getParameter("email");
19:     Class.forName("com.mysql.jdbc.Driver");
20:     java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/pms","root","root");
21:     Statement st=con.createStatement();
22:     ResultSet rs;

Make sure you have the datbase driver (the MySql jar file) in the tomcat bin folder.确保在 tomcat bin 文件夹中有 datbase 驱动程序(MySql jar 文件)。 Restart tomcat and try again.重新启动tomcat并重试。

我将 mysqljavaconnector.jar 放在 D:\\tomcat9\\lib 中,它可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM