0

增加响应缓冲区后收到以下错误:

SEVERE: Servlet.service() for servlet jsp threw exception java.lang.NullPointerException
    at org.apache.jsp.redirects.redirects_005flist_jsp._jspService(redirects_005flist_jsp.java:325)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)

我在 JSP 中添加以下行:

Welcome <%=userSession.getFirstName() %>!

由于用户会话为空,它应该重定向到登录页面,但它不是,当它到达上面的行时,它会抛出异常。

4

2 回答 2

0

基本上你应该在每次使用时更换

resposnse.redirect("abc.jsp");

RequestDispatcher rd = request.getRequestDispatcher("abc.jsp");
        rd.forward(request, response);

从您第一次在项目或会话中使用它开始

于 2013-10-03T17:28:53.240 回答
0

我认为响应是在sendRedirect()发生之前做出的。

响应提交可能由于原因导致响应提交

于 2012-07-03T06:43:25.167 回答