What is the difference between request forwarding and redirection?

What is the difference between request forwarding and redirection?

The differences are as follows:

(1) Request forwarding is one request and one response; while redirection is two requests and two responses
(2) The address bar address will not change before and after the request is forwarded; and the address bar address will change before and after the redirect
(3) Request The request object before and after the forwarding is the same, which can cooperate with the request domain object to bring data to the destination; the request object before and after the redirection is not the same, and the request domain object cannot be combined with the data before and after the redirection.
(4) Request forwarding requires two The two resources must belong to the same web application; the two resources to be redirected can be the same web application, or not the same web application, or even come from different hosts or servers.

Comparison diagram 1:

Request forwarding (forward)
Insert picture description here
redirection (redirect)
Insert picture description here

Comparison diagram 2:

Request forwarding (forward)/redirection (redirect)
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45385905/article/details/111601687