• Post Reply Bookmark Topic Watch Topic
  • New Topic

Advantages of redirect over forward  RSS feed

 
Ritika Saxena
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we compare the Redirect and Forward mechanism, we find that:
1. In Forward, the client does not come to know that the request is being directed to a different address while in Redirect, the client knows that.
2. While using Forward, the request attributes are available to the new request while in Redirect it is not so.
3. Forward is faster as compared to Redirect.

Looking into these points, it is pretty clear that Forward is better than Redirect. I have read that at some places, it is preferred to use Redirect but I could not figure out the reason for that.

Can anyone please give me any practical situation where Redirect is preferred over Forward.

Thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes you want the client to know that the URL has changed.

Sometimes forward isn't possible, e.g. to a URL on a different host.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is a saw better than a drill?

They're two different tools.
Which is best depends on the task at hand.
 
Atishay Jain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What i think is, when you want that the person should be out your application server and the logic is handled by the different application server by using just some of the parameters (or none), then you use "redirect" to transfer the request.

And one more reason is, the attributes there in the present application server with the servlet's thread object will be diminished, as the other application is going to handle it.
This will release the space in the present application server.


Let me know if you are satisfied with the answer.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66152
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ritika Saxena:
Looking into these points, it is pretty clear that Forward is better than Redirect.


Like most blanket statements, this one is absurd.

As the other experienced members pointed out, each is a different tool that is appropriate in different situations. To say one is better than the other for all situations is nothing short of ridiculous.

For example, please let us know how to implement the vital Post-Redirect-Get pattern without using redirect?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!