JSP登陆验证代码: <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.util.*" import="java.io.*" import="java.lang.*" errorPage="" %> <!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=gb2312">
<title>无标题文档</title> </head>
<body> <% //获得请求 String id=request.getParameter("username"); String psw=request.getParameter("password"); //连接数据库 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); String url="jdbc:odbc:TestData"; Connection con=DriverManager.getConnection(url); Statement stmt=con.createStatement(); String isCorrect="select * from user where username='" + id + "' and password='" + psw + "'"; ResultSet result=stmt.executeQuery(isCorrect); session.setAttribute("isLog",new String("0")); if(!result.next()) { response.sendRedirect("title.jsp"); result.close(); stmt.close(); con.close(); } //如果查询后有记录,说明登陆成功 else { //保存登陆信息到session对象中 session.setAttribute("userid",result.getString("userid")); session.setAttribute("id",result.getString("username")); session.setAttribute("email",result.getString("email")); session.setAttribute("isLog",new String("1")); stmt.close(); con.close(); response.sendRedirect("title.jsp"); } %> 输入数据库中的ID和password后TOMCAT给出的错误信息:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] ?????????????? org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800) org.apache.jsp.DATA.login_jsp._jspService(login_jsp.java:95) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] ?????????????? sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106) sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263) sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:2525) sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:337) sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:252) org.apache.jsp.DATA.login_jsp._jspService(login_jsp.java:66) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248) javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
note The full stack trace of the root cause is available in the Tomcat logs. 请高手指教怎么修改!!!请请!