The difference between servlet redirection and redirection

  • Forwarding : Request forwarding refers to forwarding the request to another address. The same request is used in the forwarding process, and the content of the forwarded address bar remains unchanged.
  • Redirection: Relocation from the original request address to a new address, the original request is invalid, and the client sees the corresponding result returned by the new request.

Let's give an example:

Forwarding process:
The client initiates a request to the servlet1 container, but servlet1 wants servlet2 to process a wave of client requests, so it calls servlet cooperation to let servlet2 process it.
Redirection process:
The client initiates a request to the servlet1 container, but servlet1 wants servlet2 to process a wave of client requests. Servlet1 calls the sendRedirect() method to redirect the client's request to servlet2, and then the browser re-requests servlet2, servlet2 do request processing

the difference

  1. different requests
  2. .After the response, whether the address bar has changed
  3. The response result of the redirection can be "outsourced"; the corresponding result of the request forwarding can only rely on the components in the same WEB application (such as another servlet page)
  4. Redirect responds directly to the browser's request, allowing the browser to re-issue a request to another URL
  5. In the process of request forwarding, the user does not know who has completed the work. The browser only knows to send the request and get the corresponding result, and does not know that the conversion behavior has occurred inside the server.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325854026&siteId=291194637