Ashwin Sridhar wrote:You need not ""return". When you use sendRedirect, the control is moved to the new page. It is a client side redirect.
if the response is not committed, why does it try IllegalstateException when we try try to do somethin with response after a sendRedirect.
Bear Bibeault wrote:Of course you need to return. All the redirect call does is to set up headers that tell the browser what to do when the response is sent. There's no magic that makes Java behave differently than it usually does. If you do not return, the rest of the code is executed as would be expected.
But it's different in a servlet?Once you redirect from a servlet, the rest of the code is not executed even if you don't return.