There is an important difference between redirection and forwarding: when using forwarding, the JSP container will use an internal method to call the target page, and the new page will continue to process the same request, and the browser will not know about this process. In contrast, the redirection method means that the first page notifies the browser to send a new page request. Because, when you use redirection, the URL displayed in the browser will become the URL of the new page, and when you use forwarding, the URL will remain unchanged. Redirects are slower than forwards because the browser has to make a new request. At the same time, since the redirection method generates a new request, the object in the request will not be available after a redirection.
How to choose whether to redirect or forward? Usually forwarding is faster and can keep the object in the request, so it is the first choice. However, since after forwarding, the URL in the browser still points to the start page, if the current page is reloaded, the start page will be called again. If you don't want to see this happen, choose forwarding.
The difference between forwarding and redirecting
Don't use session scope just to pass variables to the next page. That will increase the scope of the variable for no reason. Forwarding may help you solve this problem.
Redirect: All variables stored in the previous request are invalid and enter a new request scope.
Forwarding: The variables stored in the previous request will not become invalid, just like putting two pages together.