Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Embedded Jetty 9 - correct Handler chain

A lot of this can be explained by looking at the embedded examples.

Ok ...
ServletContextHandler is your "web application"
SessionHandler is part of the ServletContextHandler, its kinda special, its for the "web application" to use.

See ServletContextHandler.setSessionHandler()

The DefaultHandler, GzipHandler, RequestLogHandler, and StatisticsHandler are part of the server side.

GzipHandler and StatisticsHandler are HandlerWrappers, you want to wrap them around what you are interested in.
RequestLogHandler is also a HandlerWrapper, but it can operate without wrapping another Handler (this mode means that it operates on all behaviors after it in the Handler tree)

You can use HandlerCollection, or HandlerList for this. 
(ContextHandlerCollection is to group together multiple ServletContextHandler or WebAppContext branches).

Your eventual tree might look like this ...

- StatisticsHandler (for all requests)
  - HandlerList  
    - RequestLogHandler
    - GzipHandler (only for ServletContext)
      - ServletContextHandler
        - SessionHandler
        - Servlets
        - Filters
        - etc..
    - DefaultHandler (always last!)
Hope this helps ...

Joakim Erdfelt / joakim@xxxxxxxxxxx

On Wed, Sep 2, 2015 at 7:22 AM, Mullo, Jussi (Nokia - FI/Tampere) <jussi.mullo@xxxxxxxxx> wrote:
I’m somewhat confused on how to bolt all the Handlers together. For example my request log stays empty no matter what...
These are my required Handlers (only one each):
  • ServletContextHandler
  • SessionHandler
  • DefaultHandler
  • GzipHandler
  • RequestLogHandler
  • StatisticsHandler
Do I need to use ContextHandlerCollection, HandlerCollection, HandlerList and how?
What should the Handler hierarchy look like when I finally call server.getHandlers() ?

jetty-users mailing list
To change your delivery options, retrieve your password, or unsubscribe from this list, visit

Back to the top