Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diiference between forward and redirect?

 
Veena Pointi
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between forward and redirect methods?

Thanks
Veena
 
Frederic Esnault
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

This is simple.

forward methods transmits request processing to another webapp element, passing request and response objects as parameters. The resource to which we forward must be IN the webapp.

redirect sends back a redirect code to the client along with the redirection URL. Client sends a new request to the specified resource. Resource may be outside webapp.

Hope this helps.
[ March 06, 2006: Message edited by: Frederic Esnault ]
 
MInu
Ranch Hand
Posts: 517
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
forward() method of RequestDispatcher is a server side activity. So the request and its associated session are available to the forwarded resource.This method is normally used for sending a request and response object to resources (servlets or JSP's)which are in the same ServletContext.

sendRedirect() method of a response object sends the url(parameter of sendRedirect() method) to the browser and the browser sends a new request to that url. sendRedirect() used to forward requests to a resource which is outside of the current web application. It is like ,opening a new browser and type your url.


correct me if i am wrong.


Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic