The role of Containner is to send the request to the servlet and then generate the response to the client. In Tomcat 4, there are four types of container: Enginer,host,context, and Wrapper. This chapter is mainly about the context and wrapper, where the context and wrapper are simple to customize.
Engine: Represents the entire Catalina servlet engines.
Host: Represents a virtual host that has multiple context.
Context: Represents a Web site, a context that has one or more wrapper
Wrapper: Represents an independent servlet.
Pipelining Tasks
The Invoke method of the variable pipeline. There is a basevalue in the pipeline, which is a must-trigger value, and pipeline can also add
more value, when the Invoke method that calls pipeline is, each value is triggered. And the smooth triggering of value depends on Valuecontext.
Hold.
The Invoke method of Contanier
Public void throws IOException, servletexception {pipeline.invoke (request, response);}
Pipeline's interface
Public Valve getbasic (); Public void setbasic (valve valve); Public void public valve[] getvalves (); Public void throws Public void removevalve (valve valve);
Valve interface
Public String getInfo (); Public void throws IOException, servletexception;
Valvecontext's interface
Public void throws IOException, servletexception;
Public String getInfo ();
Context and Wrapper
The context has a hash type of children, which is a hash table for wrapper. The context uses the basevalue of his pipeline to find the appropriate wrapper based on the request, and then invokes the wrapper invoke method to process the request. The wrapper invoke also calls the basevalue of pipeline in wrapper to create the servlet and then the service (req,res).
How Tomcat work Porter Chapter 5:container