日期:2014-05-17  浏览次数:20891 次

java.lang.NullPointerException
知道这是初级问题,本人小白还望高手指点
Tomcat报错:
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: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

root cause

java.lang.NullPointerException
org.apache.jsp.login_jsp._jspService(login_jsp.java:85)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

login_jsp.java:85代码为:
85 if(!rs.next())//结果集没有找到所要查找的行
86 {
87 out.println("<script language='javascript'>alert('用户名或密码错误');"+
  "parent.location.href='index.jsp';</script>");
  }
  else
  {
  session.setAttribute("username",rs.getString("username"));//保存登录信息到session对象中
  session.setAttribute("password",rs.getString("password"));
  session.setAttribute("isLog",new String("1"));//将isLog属性设置为1

在线等,求教!

------解决方案--------------------
if(rs != null)
{
 if(!rs.next())//结果集没有找到所要查找的行
{
out.println("<script language='javascript'>alert('用户名或密码错误');"+
"parent.location.href='index.jsp';</script>");
}
else
{
session.setAttribute("username",rs.getString("username"));//保存登录信息到session对象中
session.setAttribute("password",rs.getString("password"));
session.setAttribute("isLog",new String("1"));//将isLog属性设置为1
//获得用户上次登录系统的时间
session.setAttribute("userLastLogTime",rs.getString("userLastLogTime"));
String strsql=calendar.getDate();
int id=rs.getInt("ID");
//将该用户本次登录系统的时间在用户信息表中更新
String strUpdate="update tb_user set userLastLogTime='"+strsql+"' where ID="+id+"";
rst.getResult(strUpdate);//执行SQL语句
response.sendRedirect("chat.jsp");//登录成功后转到系统主页面
}

}
else
{
out.print("错误");
}
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html