You can back from Servlet B to Servlet A, but request will be new one not the same request object.
Author and all-around good cowpoke
Joined: Mar 22, 2000
The second line "I am back in A" will work only in case of dispatcher and not redirect.
Think about the request Thread of execution.
The sendRedirect causes the sending of a response back to the client, but the Thread continues executing in the original servlet. Since the response has been sent, you cant write anymore to the client.
The Thread can write to a log or clean up resources, but generally, you should just return.
By returning from the doGet or doPost you return control to the servlet container.
In the meantime the client has generated a new request to the redirected URL - that gets a completely different Thread.
Joined: Mar 23, 2010
ok guys, now i got it.
since finally is there in the jvm stack, it has to be executed anyway unless i shut down jvm using System.exit();
but the main thing is that once the redirection takes place the request response cycle will be different and the old request/ response will not be available.