• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error : Response has already been committed

 
malla kiran
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have been getting the following errors on my site while redirecting from one page to another:
1)Response has already been committed.
2)Cannot forward because the response has already been committed.
One solution according to me is to increase the buffer size of jsp page from 4k to some other value, but htis does not seem to be a feasible solution to be put across site .
Can anyone suggest some other solution.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"mallakiran",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp.
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Thanks.
Dave
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mallakiran,
you may need to clear the buffer before redirecting. look at reset and resetBuffer of ServletResponse.
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and/or you may need to increase the buffer size so that the response does not get committed.
[ July 10, 2002: Message edited by: Rahul Mahindrakar ]
[ July 10, 2002: Message edited by: Rahul Mahindrakar ]
 
Sreerama Raju
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kiran,
Just try to avoid using out.println() methods and n e html content before redirecting or Forwarding page.
Regards
Sreerama Raju
 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
As Sreerama suggested there are three solutions you can undertake
1) clear the buffer
2) do not write to the out PrintWriter till you have decided that you want the response committed try using appending the response to a StringBuffer
3) Increase Buffer size ( this has a performance cost perhaps )
regarding
what about flushing the buffer solution someone posted on the group. I couldn't get this solution.If i flush teh buffer isn't it like i am commiting the response myself before redirecting instead of teh system commiting it...how can that solve teh problem at hand
you are doing the opposite of what you should be doing . By flushing the buffer you are committing the buffer.
My solution : use solution 2
Thanks
Rahul
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!