写了一个简单的登录页面,运行时出现了错误,不知道如何修改,请大家帮忙看看!
错误:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /login.jsp
Generated servlet error:
password cannot be resolved
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 12 in the jsp file: /login.jsp
Generated servlet error:
password cannot be resolved
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.
源码如下:
<%@ page language="java" contentType="text/html;charset = gb2312"
pageEncoding="gb2312"import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%!String StrDBDriver="sun.jdbc.odbc.JdbcOdbcDriver";%>
<%!String StrURL="jdbc:odbc:dl"; %>
<%!String StrDBUser="sa";%>
<%!String StrDBpwd=null; %>
<%!String strSql = null;%>
<%!Connection conn = null;%>
<%!Statement stmt = null;%>
<%!ResultSet rs = null;%>
<%String user=request.getParameter("user");
String passwd=request.getParameter("password");
try{
Class.forName(StrDBDriver).newInstance();
}
catch(ClassNotFoundException ey)
{
out.println("数据库驱动程序没找到!......");
}
catch(Exception ex)
{
out.println("数据库驱动程序没找到!.......");
}
try
{
Connection conn = DriverManager.getConnection(StrURL,"sa","");
//Statement stmt = conn.createStatement();
stmt = conn.createStatement();
out.println("数据库驱动URL正确.....");
if (stmt!=null)
{
//out.println("Connection Sucess!");
rs=stmt.executeQuery("select * from dl where name ='"+user+"' and passwd = '"+password+"'");
}
if(rs!=null)
{
out.println("Login Sucess!,Continue");
}
else
out.println("Connection fail!,try!");
}
catch(SQLException ey)
{
out.println(ey.toString());
out.println("SQLException!");
}
%>
<%@ page contentType = "text/html;charset = gb2312" %>
<html>
<head>
</head>
<body bgcolor =#D7EAFF >
</body>
</html>