java.lang.IllegalStateException: Cannot forward after response has been committed
I encountered this error while working on the final module of my project earlier. The error was obvious to me though that it occured in one of my included JSP's. <center>
normally, I wouldn't have any problems doing this. But it looks like there was quite a huge amount of processing going on with those included JSP's and even the Servlet from which this set of JSP tags page was forwarded from.
//Sample servlet code that demonstrates how much processing is being done on the servlet.DBHelper dao = new DBHelper();
request.setAttribute("positionTypesList", dao.selectPositionTypes() );
There was no time think of optimizing the code. I had to resolve to a simple hack and maybe it was really the last card that I have.
Problem was actually solved with this single line of code
<%@ page buffer="16kb" %>
I think the default buffer size for JSP is 8kb. When you get too much output to generate more than that it results to a IllegalStateException: Cannot forward after response has been committed. Why? Because I think the buffer is being flushed right away even before the response is completed so we have to set the default buffer size explicitly. Fore more info on how to solve this problem, check out these links.