Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

return statement after response.sendRedirect()  RSS feed

 
peter paul prog
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it always recommended or it makes a difference to place a return statement after response.sendRedirect() line?

i.e.
if( done ){
response.sendRedirect("result.jsp");
return;
}

thanks!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You either need to put it there or branch your code in such a way that the call to sendRedirect or requestDispatcher.foward is the last thing that happens.


More specifically, you need to insure that no code that tries to write to the output stream is executed after a call to either of those methods.
See:
http://faq.javaranch.com/java/IllegalStateException
[ January 16, 2008: Message edited by: Ben Souther ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!