1 | <%"text/html;charset=gb2312" import="java.util.*"%> contentType= |
如果是这样的话
request.getRequestDispatcher(“/index.jsp”).forward(request, response);
这条语句跳到index.jsp页面后 如果刷新则会出现一下异常1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34HTTP 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: An exception occurred processing JSP page /admin/logout.jsp at line 9
6: <body>
7: <%
8: request.getSession().invalidate();
9: request.getRequestDispatcher("/index.jsp").forward(request, response);
10: //response.sendRedirect("/research/index.jsp");
11: %>
12: </body>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
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)
com.fitler.bean.Filter_Login.doFilter(Filter_Login.java:42)
com.fitler.bean.Filter_chinese.doFilter(Filter_chinese.java:21)
root cause
java.lang.IllegalStateException: Cannot forward after response has been committed
org.apache.jsp.admin.logout_jsp._jspService(logout_jsp.java:63)
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)
com.fitler.bean.Filter_Login.doFilter(Filter_Login.java:42)
com.fitler.bean.Filter_chinese.doFilter(Filter_chinese.java:21)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
使用response.sendRedirect(“/research/index.jsp”);重定向过去就没有这个问题,
问题解决,但是还未具体研究为什么