GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE
Go To First  |  Previous Question  |  Next Question 
 J2EE  |  Question 79 of 104    Print  
How do you redirect in JSP and in Struts?

  
Total Answers and Comments: 3 Last Update: January 11, 2008     Asked by: vijay 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 20, 2007 00:31:11   #1  
g4java Member Since: July 2007   Contribution: 28    

RE: How do you redirect in JSP and in Struts?

response.sendRedirect( PATH );

 
Is this answer useful? Yes | No
September 26, 2007 01:36:31   #2  
nirajthacker        

RE: How do you redirect in JSP and in Struts?

If you use response.sendRedirect( path ) you will lose your request object.
Use requestDispatcher.forward( path ) to retain your request object.


 
Is this answer useful? Yes | No
January 11, 2008 05:07:00   #3  
mabhijit Member Since: January 2008   Contribution: 5    

RE: How do you redirect in JSP and in Struts?
There are two ways to redirect a request from JSP. They are
1). response.sendRedirect("Path");
2). requestDispatcher.forward("path");
Now the difference b/t these two are :-
1).sendRedirect() does not pass request and response object forward() passes req and res objects. Means new request is created in the sendRedirect method but forward() passes the same request object in the chaining.
2). When we use sendRedirect method then u r changing or transfering the request to new URL.Mean new URL is formed .In case of Forward method of RequestDispatcher your context is not changed means ur URL object remains same
3). If we want to send a request in inter-application then we can use sendRedirect().
4). In forword() the request is sent to another page with in the webapplication only. where as sendredirect() will sent the respone to another web application.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape