JAVA WEB: The difference between request forwarding and redirection

Source: Internet
Author: User

Sevlet response There is a way to redirect us to introduce you first.

The Sendredirect (String Local) method of a 1.HttpServletResponse object is called a redirect. If the location address is preceded by a

"/" means a request is made relative to the root of the servlet container, i.e. http://localhost:8080, if the location address money does not add "/", then the address is found relative to the URL of the current request.

The forward (request, response) of 2.RequestDispatcher is called forward forwarding .

3.

The essential difference between request forwarding and request redirection is whether to end a request cycle, and the resulting new requests

1) Request forwarding, the entire process is in the same request.

2) redirect, actually the viewer will send two requests like a server.

3) Requestdispatch is obtained by means of the Getrequestdispatch () method of the HttpServlet object, which is the method that belongs to the request object.

4) Sendredirect is the method of the HttpServletResponse object, that is, the method of the response object, since the method of the response object is called, it indicates that the entire request process has ended, the server began to want the client to return the results of execution.

5) redirect in Firebug

JAVA WEB: The difference between request forwarding and redirection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.