• Post Reply Bookmark Topic Watch Topic
  • New Topic

I get this forward a response error when I submit my form  RSS feed

 
rastas biggs
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I check for errors and redirect if error is true, now would the code below
being if both conditions are met cause this exception?


java.lang.IllegalStateException: Cannot forward a response that is already committed
DEBUG [12:35:31] (Form.java oGet:250) - doGet(HttpServletRequest, HttpServletResponse) - doGet: do post passed
DEBUG [12:35:32] (Activate.java oGet:67) - doGet(HttpServletRequest, HttpServletResponse) - doGet





 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once the response is redirected, we can't again redirect the response. In your logic this happens. Set the page name accordingly in the if conditions and use a single redirect out side of the if block

regards
 
Chit Ming Chong
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adding a reture statement after the call to redirect may help
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither the 'sendRedirect' call nor the 'forward' call will stop the execution of your servlet or JSP.
You should either set up your branching (as Sarath has pointed out) in such a way to handle this or (as Chit Ming Chong has suggested) enter a 'return' statement just after any calls to sendRedirect or forward.


[ April 21, 2005: Message edited by: Ben Souther ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!