Friday, June 29, 2007

"Response already been committed - Web Application"

The server maintains a buffer for the content that is to be written out to the client. When this buffer is filled to capacity the default action is to flush the content to the client while fresh content is loaded into the buffer.Now, it is illegal to do a forward once the output is committed i.e the buffer has been flushed to the client - this is the source of the error('Response already been committed') .To solve this problem you will have increase the size of the buffer from the default size ( this depends on the application server you are using) to a size,which will not overflow until all the page content is loaded into it so that you have suffcient time to decide if you must flush the buffer to the client or clear the buffer so that you may forward it to the error page.
To increase the buffer size, include the page directive in the JSP page , the page directive would look like this :
<%@ page page-attribute-list %>
In the attribute list for the buffer attribute provide a size in KB - this will be by trial and error as if the size of your Header , Sidebar exceed your buffer size the buffer would be flushed.Another attribute that you may set is auto flush the default value of which is true. If you set it to false it becomes your responsibility to flush the buffer when it is full.

Note : I faced this problem and i found this answer in one of the sun forums and thought good answer ..let me share it ..

0 comments: