Java Forwarding and redirection

Source: Internet
Author: User

1, Request redirect: Client behavior, Response.sendredirect (), essentially equivalent to two requests, the previous request object will not be persisted, the Address bar URL will change.

2, Request Forwarding: Server behavior, Request.getrequsetdispatcher (). Forward (requset,response); is a request, the request object will be saved after forwarding, the Address bar URL address will not change. (Server internal forwarding, all clients do not see the change in the address bar)

Here is an example of life that illustrates:
Request redirection: Just like we find a advertising company to design business cards, a clearly tell us that they will not design, let us find B company, the result B company designed for me, so we will announce the company B to us the design of the business card, (so we are equivalent to send two times the request, The URL address bar has changed from A to Company B)

Request Forwarding: Also to find a company to design business cards, although a company can not design but they took our lives, the task of outsourcing (forwarding) to company B, and eventually we will give money to company A, It's going to be a business card designed by company A. This is the request redirection (so we're just sending a single request to a, and the URL address bar is still company a).

Java 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.