The servlet lifecycle is managed by a Web container, such as Tomcat, and is initialized one time until the Web container is closed before it is destroyed.
1. The servlet is a singleton multi-threaded, and each request comes in a container to enable a new thread
2. The servlet maintains a singleton in the container and is initialized only once
When the servlet configuration Load-on-startup is a positive integer in Web. XML, the servlet initializes when the container starts: Create object->init (servletconfig config)->init ()
When Load-on-startup is not set or the value is negative, the servlet is initialized when it is requested: Create object->init (servletconfig config)->init ()
3. A request comes over the container will start a new thread, wrapping HttpServletRequest and HttpServletResponse to the servlet, triggering the servlet's service method, The service method calls the corresponding method (Doget, DoPost, DoPut, DoDelete ...) based on the methods specified by the request.
Recommended Literature: Http://blog.chinaunix.net/uid-9789791-id-1997412.html
The relationship between the Servlet life cycle and the Web container