There are four types of container,engine,host,context,wrapper in Tomcat 4 and 5, and the simplecontext,simplewrapper that you have written has been briefly introduced. This chapter is about the Standardwrapper of Catalina.
The first wrapper is to represent a servlet, so the role of wrapper is to load the servlet class, the servlet information, and the Fiter to the servlet, as well as the fiter load, fiter.
1.servlet can inherit the Javax.servlet.SingleThreadModel (STM) interface
This ensures that a servlet instance will only appear in one thread.
However, there is no guarantee of thread safety, and if a global variable is used in a servlet, there will be an issue with thread execution errors.
This is achieved through the servlet pool.
If the Javax.servlet.SingleThreadModel interface is not inherited, it is returned directly if the servlet instance already exists.
2.servlet of loading
First call the Init method, passing an instance of Javax.servlet.ServletConfig. Call the Load method again
Because Catalina supports the loading of JSP classes, it checks whether the requested page is JSP, and if so, gets the wrapper that loads the JSP from the parent container, which is the context, and then gets the class name of the Servlet class that is used to load the JSP.
Loading the servlet triggers some event listener functions.
3.ServletConfig
In addition to inheriting the Wrapper interface interface, Standardwrapper also inherits the Javax.servlet.ServletConfig interface.
Public publicPublic publicvoid Public publicPublic public
4.StandardWrapperValve
Responsible for executing the servlet filter, and executing the service method.
Creates a filter, created by the information of an instance of the Filterdef class, and Applicationfilterconfig class is also created by an instance of the Filterdef class
Applicationfilterchain to perform various filter
How Tomcat work Porter Chapter 11:standardwrapper