Re: [jetty-user] adding a filter programmatically
Philippe Marschall <kustos <at> gmx.net>
2010-01-09 08:57:39 GMT
On 02.01.2010 00:32, Greg Wilkins wrote:
> there is the javadoc:
> which is a little light on, but fairly self evident.
> I guess we should add a filter example to the embedded tutorial:
> if somebody wanted to contribute a simple example, then I'd add
> it to embedded examples and describe it in the tutorial.
There is one thing about adding filters that wasn't quite obvious to me.
If you application is just a filter (e.g. Wicket) then you still need to
add a "NullServlet".
I use something like this to add filters:
int options = ServletContextHandler.NO_SECURITY;
ServletContextHandler context = new ServletContextHandler(server, "/",
context.addFilter(MyFirstFilter.class, "/*", FilterMapping.REQUEST);
FilterHolder secondFilter = new FilterHolder(MySecondFilter.class);