Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sendRedirect and forward

 
Ghulam Rasool
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We know that incase of forward there is not a full network round trip and same request object is forwarded .. while in sendRedirect there is a full network roundtrip and a new request object is created. there is a temptation to use forward. The Question is that in what cases we should prefer to use the sendRedirect method instead of forward ? which one is better and why ?
 
Pearlo Muthukumaran
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Your answer is true from the resultant effect point of view. But at the background, redirect results in forwarding the URL to the client and client re-requesting the URL.
Forward
- is a kind of redirect to the resource within the same server
- no client involvement is required
Redirect
- as explained above
therefore, use forward when the redirected resource resides on the same server and use redirect when the resource resides on a different server
Hope this clarifies
Rgds
Muthu
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might consider redirect when you want the browser client to know the new URL. That lets the user refresh or bookmark the page. TheServerSide.com proposed a pattern of posting an edit form to the server, then redirecting the browser to an inquiry URL that displays the changed content. The overhead of a second request-response cycle may be acceptable given the improved usability of the site.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic