Java Web container Start-up process

Source: Internet
Author: User
Tags java web

The process of starting and processing requests for the Java Web container

1. When starting a Web project, the Web container goes back to read its config file, XML, and reads <Context-param> nodes.

2. The container creates a ServletContext (servlet context), and all parts of the Web project will share this context.

3. The container converts <context-param> into a key-value pair and ServletContext. Because components such as listener,filter use information about these contexts when they are initialized, they are loaded first.

4. Create a <listener> class instance of the container and create the listener.

5. Loading the filter and servlet

The Load-on-startup element specifies the order in which the servlet is loaded when the-web application is started, and its value must be an integer. If its value is a negative integer or the element does not exist, the container will load the servlet when the servlet is called. If the value is a positive integer or 0, the container loads and initializes the servlet when it is configured. The container must ensure that the values are loaded first, and if the values are equal, the container can automatically choose who to load.

The load order for Web. XML is: Context--param--listener--filter--servlet

The process by which a container handles requests

When the Web container receives the request information from the client, it finds the corresponding Servlet object in the servlet queue based on the Web Component address information in the URL, and if found it is used directly, loads the corresponding class if it is not found, and creates the object. In other words, the Servlet object was created the first time it was used, and once created it is reused and no new objects are created. All created servlet objects are garbage collected uniformly when the Web server stops running.

Java Web container Start-up process

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.