I. Introduction of the Servlet
Second, the operation of the servlet process
The servlet program is called by the Web server after the Web server receives a servlet access request from the client:
- The Web server first checks to see if the instance object for the servlet has been mounted and created. If so, perform step 4th directly, or step 2nd.
- Mount and create the init () method for the Servlet instance object
- Invoking the Init () method of the Servlet instance object
- Create a HttpServletRequest object that encapsulates the HTTP request message and a HttpServletResponse object that represents the HTTP corresponding message, and then call the servlet's service () method, and the request and response objects are passed in as parameters.
- Before the Web application is stopped or restarted, the servlet engine uninstalls the servlet and invokes the servlet's Destory () method
Third, servlet call graph
Iv. servlet Access URL mapping configuration
The same servlet can be mapped to multiple URLs, that is, the set value of the <servlet-name> child elements of multiple <servlet-mapping> elements can be the registered name of the same servlet
<servlet> <description></description> <display-name>servletdemo1</display-name> ; <servlet-name>ServletDemo1</servlet-name> <servlet-class>com.atguigu.servlet.servletdemo1</servlet-class> </servlet> <!--the same servlet can be mapped to multiple URLs--<servlet-mapping> <servlet-name> Servletdemo1</servlet-name> <url-pattern>/servletDemo1</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletDemo1</servlet-name> <url-pattern>/1.html& lt;/url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>servletdemo1</ser vlet-name> <url-pattern>/2.htm</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletDemo1</servlet-name> <url-pattern>/3.htm</url-pattern> </ Servlet-mapping>
Javaweb Learning Summary _servlet Development