我真的需要一个人来救我。我上次非常感激,我发布了一个问题。不幸的是,同样的问题/类似的问题仍然会持续近2个月。由于这个驱动程序问题,我无法完成我的项目'。我安装了几个J / Connectors但仍收到HTTP错误消息。所以我决定使用MySQL安装程序来安装所有组件,这次收到以下错误消息:
HTTP Status 500 - An exception occurred processing JSP page /login.jsp at line 6
type Exception report
message An exception occurred processing JSP page /login.jsp at line 6
description The server encountered an internal error that prevented it from fulfilling this.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 6
3: <%
4: String userid = request.getParameter("uname");
5: String pwd = request.getParameter("pass");
6: Class.forName("com.mysql.jdbc.Driver");
7: Connection con = DriverManager.getConnection
8: ("jdbc:mysql://localhost:3306/REG",
9: "root", "$jademedia247");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.login_jsp._jspService(login_jsp.java:93)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:126)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:169)
org.apache.jsp.login_jsp._jspService(login_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.50 logs.
Apache Tomcat/7.0.50'
CLASSPATH:C:\ Program Files \ MySQL \ Connector J 5.1.28 \ mysql-connector-java-5.1.28-bin.jar; C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ lib \ jsp-api.jar; C:\ Program Files \ Java \ jdk1.6.0_38 \ jre \ lib
路径:C:\ Program Files \ MySQL \ MySQL Server 5.6 \ bin; C:\ Program Files \ Java \ jdk1.6.0_38 \ bin; C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ bin; C :\ Program Files \ MySQL \ MySQL Utilities 1.3.6 \
的login.jsp
<%@ page import="java.io.*,java.util.*,java.sql.*" %>
<%@ page import="javax.servlet.http.*,javax.servlet.*"%>
<%
String userid = request.getParameter("uname");
String pwd = request.getParameter("pass");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/REG",
"root", "$jademedia247");
Statement st = con.createStatement();
ResultSet rs;
rs = st.executeQuery("select * from members where uname='" + userid + "' and pass='" + pwd + "'");
if (rs.next()) {
session.setAttribute("userid", userid);
//out.println("Welcome" + userid);
//out.println("<a href='logout.jsp'>Log out</a>");
response.sendRedirect("Success.jsp");
} else {
out.println("Invalid password <a href='form.jsp'> try again </a>");
}
%>
registration.jsp
<%@page import ="java.sql.*"%>
<%
user = request.getParameter("uname");
String pwd = request.getParameter("pass");
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String email = request.getParameter("email");
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection
("jdbc:mysql://localhost:3306/REG","root", "$jademedia247");
Statement st = con.createStatement();
//ResultSet rs;
int i = st.executeUpdate("insert into members (first_Name, last_Name, email, uname, pass, regdate) values ('" + fname + "', '" + lname + "', '" + email + "','" + user + "', '" + pwd + "', CURDATE())");
if (i > 0) {
//session.setAttribute("userid", user);
response.sendRedirect("welcome.jsp");
//out.print("Registration Successfull!"+"<a href='form.jsp'>Go to Login</a>");
} else {
response.sendRedirect("form.jsp");
}
%>
文件路径:C:\ Program Files \ Apache Software Foundation \ Tomcat 7.0 \ webapps \ ROOT
CREATE TABLE `members` (
`id` int(10) unsigned NOT NULL auto_increment,
`first_name` varchar(45) NOT NULL,
`last_name` varchar(45) NOT NULL,
`email` varchar(45) NOT NULL,
`uname` varchar(45) NOT NULL,
`pass` varchar(45) NOT NULL,
`regdate` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
刚刚创建了一个数据库REG。
答案 0 :(得分:2)
将文件 mysql-connector-java-5.1.28-bin.jar 放在tomcat_dir/lib/
内。