Request processing
As we saw in the last chapter, the context's basic valve first notifies any ServletRequestListener
instances by invoking their requestInitialized()
method, and then calls invoke()
on the servlet wrapper's pipeline.
A wrapper's pipeline, by default, only has a single valve, the StandardWrapperValve
. It calls its wrapper's allocate()
method to obtain an instance of its wrapped servlet to process the incoming request.
If this is a normal servlet (that is, it does not implement the deprecated SingleThreadModel
interface), then there will always be only one instance of a given servlet per wrapper, and it is this instance that is returned to service every incoming request for this servlet.
While servlets that are marked to be loaded on startup are instantiated and initialized by the context within its start()
method, the rest are lazily initialized on first use.
The wrapper is requested to allocate a servlet instance to handle this request. If an instance has not yet been allocated...