急求!!!!请各位大侠帮帮忙,错误!
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:532)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:426)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NullPointerException
org.apache.jsp.WebRoot.EnterPage.judge_jsp._jspService(judge_jsp.java:113)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
源代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>Insert title here</title>
</head>
<body>
<%
String userName = request.getParameter("number");
String password = request.getParameter("password");
String str1 = null;
//out.println(userName);
Statement st = null;
Connection con = null;
ResultSet rs = null;
int i = 0;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:sun");
st = con.createStatement();
String sql = "select * from userInformation";
rs = st.executeQuery(sql);
while(rs.next()){
String str = rs.getString(2);
if(str.equals(userName) && str.equals(password))
{
str1 = str;
i ++;
}
}
if(i == 0)
{
String s = "您输入的用户名或密码错误";
String errorInfo = new String(s.getBytes("GB18030") , "ISO-8859-1");
response.sendRedirect("EnterPage.jsp?errorInfo=" + errorInfo);
}
else if(i == 1)
{
response.sendRedirect("/StudentSystem/TheMainPage/TheMainPage.jsp");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try {
rs.close();
st.close();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
%>
</body>
</html>
在别人的电脑上能运行,我怀疑我的配置有问题tomcat6.0+Myeclipse+sql 2000
------最佳解决方案--------------------------------------------------------
空指针异常。
别人电脑上能运行说明代码没有问题。
所以应该是数据库连接配置问题。
st = con.createStatement(); 估计是con为null导致异常。debug和system.out一下,很容易就能看出来的