开发者

java.lang.IllegalStateException: Cannot create a session after the response has been committed

I've got this really strange request for an invalid URL on:

Invalid URL: /cgi-bin/1st.cgi

This is causing the following error:

 SEVERE: Exception initializing page context
java.lang.IllegalStateException: Cannot create a ses开发者_开发问答sion after the response has been committed
        at org.apache.catalina.connector.Request.doGetSession(Request.java:2381)
        at org.apache.catalina.connector.Request.getSession(Request.java:2098)
        at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
        at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
        at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:544)
...

How can I solve this issue?


What's happening is the response stream has been closed. Either you already sent a redirect, or committed some other type of response. I recommend getting your session object before you perform any response, and save the response until there is nothing left to do with the HttpServletRequest or HttpServletResponse objects.

A good practice is to return from your Servlet right away after performing a redirect, that way you can avoid some of these problems.


I had this problem because of multiple tag <h:outputScript target="head">

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜