Difference between JSP forward and redirect.
Ref:http://stackoverflow.com/questions/6068891/difference-between-jsp-forward-and-redirect
Explanation_01:
- redirect sets the response status to 302 [1], and the new url in a Location header, and sends the response to the browser. Then the browser, according to the http specification, makes another request to the new url.
- forward happens entirely on the server. The servlet container just forwards the same request to the target url, without the browser knowing about that. Hence you can use the same request attributes and the same request parameters when handling the new url. And the browser won’t know the url has changed (because it has happened entirely on the server).
Explanation_02:
I’ve heard interesting explanation of redirect and forward. Imagine that you need some service from your friend.Its doesn’t matter what service. Suppose that your friend can’t help you but know who can.
He would REDIRECT your request if he will tell you: “I can’t handle this but know who can.Here his phone number. Call him”.
He would FORWARD your request if he will tell you: “No problem” and call that man by himself without noticing you about involving another person in handling your desire. Then your friend wil get result of soring out your wish and transmit to you.
Explanation_03:
Redirect:
1.User requests a resource.
2.Response sent to the user.
3.This is not the requested resource, this is response with HTTP code 302 and contains the URL of the requested resource.
4.URL could be same or different from the requested URL.
5.Client browser makes request for resource again with the new URL, this time the actual resource is sent to the user.Forward:
It is the process of simply displaying the requested resource to the user. It happens entirely on the server side.
by Mike Sun, March 22, 2017;