How Tomca implements the Servlet specification and the functions implemented by the Context component

The most important in the Servlet specification are Servlet, Filter and Listener. The most important function of web containers is to create them and call their methods when appropriate.

Tomcat manages Servlet through Wrapper container, Wrapper wraps Servlet itself and corresponding parameters, which embodies the design principle of "encapsulation" in object-oriented.
Tomcat will generate a Filter chain for each request, and the last Filter in the Filter chain will be responsible for calling the service method of the Servlet.
For Listener, we can customize our own listener to listen to various events that occur inside Tomcat: including Web application level, Session level, and request level. The Context container in Tomcat maintains these listeners uniformly and is responsible for triggering them.

The Context component is a very important component in Tomcat. It implements hot loading under Context (hot deployment is implemented at the host layer), tomcat class loader, multiple web application isolation, and implementation of Servlet specifications

Guess you like

Origin blog.csdn.net/Wangdiankun/article/details/105821234