终有弱水替沧海4032800
2016-11-18 21:16
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");
}
}
你可以打断点java单步调试一下,可以简单先分析一下:你报500错误,是内部错误,也就是你访问servlet错误,原因是
type Exception report
message java.lang.NullPointerException
和
root cause
java.lang.NullPointerException
空指针异常。
看你部分代码
String username = request.getParameter("username");
String password = request.getParameter("password");
这两句最有可能是异常所发生地方,如果是,你可以检查一下,jsp页面的用户名的name属性和用户名的密码属性,是否是username和password;如果不是,请你单步调试,精准找到报错代码,再解决。
JAVA遇见HTML——Servlet篇
160613 学习 · 1029 问题
相似问题