Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why we need send redirect?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I know what send redirect means, it is used to redirect the request to some other resource. One more thing is client can see the different URL on browser.

What I want to know is, why we need this? In which situation we can use send redirect?

Can't we use forward in all situation, I suppose, it is always better to hide such thing from client.

Please comments.
Thanks.
[ November 08, 2005: Message edited by: rathi ji ]
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi rathi ,

sendRedirect must be used when redirecting to a page outside the current context. for instance, I could not forward a request from my domain to a page inside www.javaranch.com.

Also, you should use sendRedirect when you want to ensure that the url is exposed to the user. For instance, if the client needs the ability to bookmark the page, you should use sendRedirect.

Also, when switching protocalls, like from http to https, I believe you need to use a sendRedirect as well.
 
subho saha
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i want something in my application should be handaled by some other web-application may be built by somebody else, for which i am not responsible in those cases I should use send redirect.
For example say my application wants currency coversion from USD to EURO then calling the yahoo finance with my currency amount may solve my problem
using send redirect.
[ October 21, 2005: Message edited by: subho saha ]
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Paul and Subho.

Paul, I think you are prepared to strike SCWCD. All the best.

 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, I think you are prepared to strike SCWCD. All the best.
thanks rathi! I've been "preparing" for a while, but right when I was ready to take it, I change jobs and moved across country... so I've been putting it off. I need to get my butt in gear again though!
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's also a way to make the browser to a GET. The POST-redirect-GET pattern has the browser POST an update then GET a fresh view of the changed data. The user can bookmark the view page or refresh it without repeating the POST. I think this is more consistent with the REST view of web architecture; POST should update the resource and GET should show it to you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic