我的页面跳转,登陆失败可以跳转,登陆成功无法跳转,显示错误如下
HTTP Status 500 - java.lang.NullPointerException
type Exception report
message java.lang.NullPointerException
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:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
root cause
java.lang.NullPointerException
org.apache.jsp.login_005fsuccess_jsp._jspService(login_005fsuccess_jsp.java:116)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.65 logs.
下面的是我的ServletLogin里的部分代码
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Users u = new Users();
String username = request.getParameter("username");
String password = request.getParameter("password");
u.setUsername(username);
u.setPassword(password);
if(u.getUsername().equals("admin")&&u.getPassword().equals("admin")){
response.sendRedirect(request.getContextPath()+"/login_success.jsp");
}else{
response.sendRedirect(request.getContextPath()+"/login_failure.jsp");
}
}