Skip to main content

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

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
mugwhy
Offline
Joined: 2012-07-15

I have a servlet that I have built and I want to distribute the servlet to people who want it. Once the servlet is deployed, it is important to me that people can insert this servlet into their webpage at any location they choose.

I'm using the glassfish webserver 3.1 Open Source version.

To give an idea I have posted a rough idea of a webpage below ( see between the lines)
I have configured the glassfish server to allow the include directive.

What I'm doing works just great but ONLY WORKS if I insert the include early in the webpage near the beginning.

If I insert the servlet near the end I get an exception thrown all the time and the servlet does not show. The exception is...
java.lang.IllegalStateException: PWC3999: Cannot create a session after the response has been committed

I have done tons of googling on this without finding a suitable answer and have come here to the forum for assistance.

What I have found is that the problem is probably to do with a 8k response buffersize being filled up before the servlet is reached.

I have tried tweaking buffer sizes in glassfish admin with no change in result. In code I con do a response.getBufferSize() but it ALWAYS returns 8192bytes regardles of any response-send-buffer settings i set in glassfish. Attempting to set this buffer size in my code is of no help because of the core issue of the servelt being included late in the page.

Include early is good. include late? problem!

Where can I configure this 8192byte buffer size in my development system. I'm ruinning windows 7.

whatEver.html
-----------------------------
html code
html code
<!--#include virtual="/web/myServlet" --> 
html code
html code
html code
html code
html code

----------------------------------

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mugwhy
Offline
Joined: 2012-07-15

Re: the example code, where that blank space is? is suppose to be an include directive.When posted it did not show.