Section 7.1.2 Handlers as Interceptors or Filters
In Jetty versions 5 and lower, handlers were called in sequence, one after the other, until the request is marked as handled. This allowed shallow call stacks, but did not allow for simple and safe before/after handling using try {} finally {} constructs.
In Jetty 6, all handlers are formed into a strict containment tree rooted to the server and the normal arrangement is for handlers to implement their aspect of handling and then delegate the request to a contained handler. For a full configuration, the handling typically happens as follows:
1.The Server delegates the request to the its configured handler, which is normally an instance of HandlerCollection.
2.The HandlerCollection acts like Jetty 5, and calls each of its contained handlers in turn. Typically, it is configured with a ContextHandlerCollection, a DefaultHandler and a RequestLogHandler. This allows a request to be handled by a context or the default handler, and then be passed to the request log handler.
3.The ContextHandlerCollection maintains a map of context path to the lists of ContextHandlers. For a given request, each of the URI is used to find matching context paths, and each is called in turn until the request is handled.
4.If the ContextHandler accepts a request (it may reject it due to virtual hosts), it will delegate the request to a nested handler and for the duration of the call it sets.
5.Typically, the ContextHandler is an instance of WebAppContext and will thus contain a nested chain of SessionHandler, SecurityHandler, and ServletHandler. The request is delegated to the first handler in this chain, a SessionHandler.
- the request context path
- the current thread context classloader
- the resource base
- the error handler
- context attributes and init parameters
6.The SessionHandler examines the request for any session ID to be activated and will activate the mechanism for creating new sessions before delegating the request to the SecurityHandler.
7.The SecurityHandler checks any constraints and authentication before delegating the request to the ServletHandler.
8.The ServletHandler implements the dispatch to Filters and Servlets to handle the request according to the servlet specification.


