The relationship between the Servlet life cycle and the Web container

Source: Internet
Author: User

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

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.