aspose file tools*
The moose likes Servlets and the fly likes use of Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "use of "sendredirect" and "forward" method in same page" Watch "use of "sendredirect" and "forward" method in same page" New topic
Author

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

anandbhucs rai
Greenhorn

Joined: Sep 10, 2005
Posts: 5
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
Sravan Kumar
Ranch Hand

Joined: Sep 11, 2005
Posts: 121
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.


keep smilin :: sravan<br /><a href="http://sravanpens.blogspot.com" target="_blank" rel="nofollow">I scribble here</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of "sendredirect" and "forward" method in same page
 
Similar Threads
HttpServletResponse Error
jsp:forward and sendredirect
images display problem with dispatcher.forward()
Differences btwn (response.sendRedirect) and (Requestdispatcher.forward)
forward