Skip to content
Advertisement

How to add servlet Filter with embedded jetty

I am embedding jetty into my app, and trying to work out how to add servlet filters (for cookie handling). The wiki and the javadoc’s dont make it very clear, what am I missing:

JavaScript

The only info I have found on this is a forum post suggesting the documentation on this needs to be improved.

Advertisement

Answer

Update: For Jetty version 9.2.2:

JavaScript

Original answer ===

If you don’t want to use web.xml then use this:

JavaScript

If you do want to use web.xml, instead of the addFilter() methods, just make sure you have a WEB-INF/web.xml in your webapp root path with the following xml:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement