Forums Register Login

use of "sendredirect" and "forward" method in same page

+Pie Number of slices to send: Send
If we use sendredirect like that :

res.sendRedirect("SomeURL"); //1
int i = 2; //2
out.println("Value of i =" +i); //3

Then Line (2) & (3) are executed or after line (1) this page is redirected
to other page ?
...............................................

Can we use both "sendredirect" and "forward" in same page ?


Thanks & Regards:
Anand
+Pie Number of slices to send: Send
The lines 2 & 3 will get executed, but nothing will be printed on the response object. You will see the redirected page on the browser.

You cannot forward and redirect from the same servlet. It will throw IllegalStateException.
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 781 times.
Similar Threads
Differences btwn (response.sendRedirect) and (Requestdispatcher.forward)
images display problem with dispatcher.forward()
jsp:forward and sendredirect
HttpServletResponse Error
forward
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:04:05.