/*** <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