File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes java.lang.IllegalStateException: Cannot create a session after the response has been committed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "java.lang.IllegalStateException: Cannot create a session after the response has been committed" Watch "java.lang.IllegalStateException: Cannot create a session after the response has been committed" New topic
Author

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

Ajay Njallacattu
Ranch Hand

Joined: Nov 21, 2006
Posts: 36
Hi,

We have deployed an Application in Tomcat which is developed using Spring. We are getting the following exception frequently in the Tomcat error log.

Can anyone help us in resolving the same?

org.apache.jasper.runtime.JspFactoryImpl internalGetPageContext
SEVERE: Exception initializing page context
java.lang.IllegalStateException: Cannot create a session after the response has been committed
at org.apache.catalina.connector.Request.doGetSession(Request.java:2433)
at org.apache.catalina.connector.Request.getSession(Request.java:2153)
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:547)
at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:493)
at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:146)
at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:124)
at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:107)
at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:63)
at org.apache.jsp.ErrorCode_jsp._jspService(ErrorCode_jsp.java:48)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:416)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:270)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:291)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Thread.java:662)


Regards

Ajay
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 11863
java.lang.IllegalStateException: Cannot create a session after the response has been committed


Somewhere in your code there is a statement which tries to create a session after so much output has been written that the response headers have been sent.

Since creating a session involves inserting a cookie in the response headers, this is not legal.

1. Rearrange your code so that session creation comes before writing output
- OR -
2. Increase the buffer size in the JSP page directive.

Bill


Java Resources at www.wbrogden.com
 
 
subject: java.lang.IllegalStateException: Cannot create a session after the response has been committed
 
Threads others viewed
PDF save in Browser?
IllegalStateException in servlet
java.lang.IllegalStateException: Cannot create a session after the response has been committed
java.lang.IllegalStateException: Cannot create a session after the response has been committed
java.lang.IllegalStateException: Cannot create a session after the response has been committed
IntelliJ Java IDE