A variety of life cycles in Java

Source: Internet
Author: User

Servlet life cycle

    1. When a servlet is requested for the first time, the servlet is instantiated, and the instance resides in memory, in response to subsequent requests! (if Load-on-startup is added to the configuration of the servlet, the servlet is instantiated directly when the server is started)

    2. After the servlet is instantiated, the init () method is called immediately, and the method is called only once between the entire life cycle.

    3. The service () method is invoked each time the servlet is requested (callback Doget,dopost)

    4. When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire servlet life cycle

Filter life cycle

    1. When the server is started, the filter is instantiated directly, and the instance will remain in memory to intercept subsequent requests!

    2. The Init method is called immediately after the filter is instantiated

    3. The Dofilter method is executed each time the filter intercepts the request.

    4. When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire filter life cycle

Interceptor (Interceptor) life cycle

    1. When the server is started, the interceptor is instantiated directly, and the instance resides in memory to intercept subsequent requests!

    2. The Init method is called immediately after the interceptor is instantiated

    3. The Intercept method is executed each time the interceptor intercepts the request.

    4. When the Web application is about to be uninstalled, the Destroy method is called, which executes only once between the entire interceptor life cycle

A variety of life cycles in Java

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.