Forward (forwarding):
Is the server requests the resource, the server directly accesses the URL of the destination address, reads the response content of that URL, and then sends the content to the browser. The browser doesn't know where the server is sending the content from, because the jump process is actually implemented by the server, is not implemented in the client, so the client does not know the jump action, so its address bar is still the original address.
Redirect (redirect):
Is the server based on logic, send a status code, tell the browser to re-request that address. So the address bar shows a new URL.
Forwarding is the server behavior, and redirection is the client behavior.
difference :
1. From the Address bar display
Forward is the server requests the resource, the server directly accesses the URL of the destination address, reads the response content of that URL, and then sends the content to the browser. The browser does not know where the server sent the content from, so its address bar is still the original address.
Redirect is the server based on logic, sending a status code that tells the browser to re-request that address. So the address bar shows a new URL.
2. From data sharing
Forward: The forwarded page and the forwarded page can share the data within the request.
Redirect: Data cannot be shared.
3. From the place of use
Forward: Generally used for user login, according to the role of forwarding to the corresponding module.
Redirect: Generally used for users to log off when landing to return to the main page and jump to other sites, etc.
4. From an efficiency standpoint
Forward: High.
Redirect: Low.
Essential Differences :
Explanation One:
In a word, forwarding is the server behavior and redirection is the client behavior. Why do you say that, it depends on the workflow of two actions:
Forwarding process: The client browser sends an HTTP request----The Web server accepts this request--a method inside the container that completes the request processing and forwarding action----"sends the target resource to the customer; here, the forwarded path must be a URL under the same Web container. It cannot be turned to other web paths, and the middle passes through the request within its own container. In the customer browser path bar is still the path of its first access, that is, the customer does not feel that the server is forwarded. The forwarding behavior is that the browser makes only one access request.
REDIRECT process: The client browser sends an HTTP request----The Web server accepts a 302 status code response and corresponds to a new location to the client's browser-the client browser finds a 302 response, then automatically sends a new HTTP request, The request URL is the new location address----The server looks for resources and sends them to customers based on this request. Here the location can be redirected to any URL, since the browser has re-issued the request, there is no concept of request delivery. The client browser path bar displays its redirected path, and the customer can observe the change of address. The redirect behavior is that the browser has made at least two access requests.
EXPLANATION Two:
Redirect, in fact, is two times the request,
For the first time, the client request A, the server responds, and response back, telling the browser that you should go to B. This time, IE can see the address has changed, and the history of the fallback button is also lit. Redirects can access resources other than their own web apps. During the redirection process, the transmitted information is lost.
Example:
Request forwarding is the processing power of a request/response within the server, handed over to another
For the client, it knows only the one that was requested first, not the middle B, or even C, D. The transmitted information is not lost.
EXPLANATION Three:
Forwarding is the server behavior, and redirection is the client behavior.
There is a big difference between the internal mechanisms of the two: 1 Request forwarding can only forward requests to components in the same web app. Redirects can also be redirected to resources in different applications in the same site, and can even be directed to an absolute URL. 2 redirects can see the URL of the target page, Forwarding only sees the URL of the page that was visited for the first time, and future work is done with the server. 3 the same Request object and the response object are shared between the requesting response caller and the callee. The redirected caller and callee belong to two separate access request and response procedures. 4 redirect After the jump must add return, otherwise the page, although jump, However, the statements following the jump are also executed, Forwarding is the execution of the jump page, the following code will not be executed. |
The difference between request forwarding (Forward) and redirection (Redirect)