(11) RequestDispatcher

Source: Internet
Author: User

/*** <p> title: requestdispatcher</p> * <p> * Function Description: * 1, RequestDispatcher objects are created by the servlet container to encapsulate a path The server resource that is identified. With the RequestDispatcher object, you can forward requests to other servlet or JSP pages. * 2, can be obtained from the ServletContext in the Getrequestdispatcher, also can be in the ServletRequest getrequestdispatcher. * 3,http://localhost: 7777/sltlearn/outservletinfo request.getrequestdispatcher ("/"); Get the path of the project, referring to sltlearn/* </p> * <p> Created: January 19, 2016 morning 10:51:18</p> * <p> Author: Love </p> * <p> version: 1.0</p>*/ Public Abstract InterfaceRequestDispatcher {/** This method is used to pass requests from one servlet to another servlet, JSP page, or HTML file on the server.      * In a servlet, you can do a preliminary processing of the request, and then call this method to pass the request to another resource to output the response.     * Note that this method must be called before the response is presented to the client, otherwise it throws a IllegalStateException exception.     * After the forward () method call, uncommitted content that was originally in the response cache is automatically purged. *      */     Public Abstract voidforward (ServletRequest paramservletrequest, Servletresponse paramservletresponse)throwsservletexception, IOException; /** This method is used to include the contents of other resources (Servlets, JSP pages, or HTML files) in the response. The difference between the * and the Forward () method is that the request is forwarded to the other servlet using the Include () method, and the response of the invoked servlet to the request is incorporated into the original response object, and the original servlet can continue to output the response information.     Instead, the forward () method is used to forward the request to the other servlet, and the invoked servlet is responsible for responding to the request, and the execution of the original servlet terminates. *      */     Public Abstract voidinclude (ServletRequest paramservletrequest, Servletresponse paramservletresponse)throwsservletexception, IOException; //Summary: The similarities between the two methods: the address of the client access will not change, or the original access to the address, the change is only the internal jump call. }

(11) RequestDispatcher

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.