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:
>
> Chad,
>
> there is the javadoc:
>
> http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/servlet/ServletHandler.html
>
> which is a little light on, but fairly self evident.
>
> I guess we should add a filter example to the embedded tutorial:
>
> http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
>
> 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, "/",
options);
context.addFilter(MyFirstFilter.class, "/*", FilterMapping.REQUEST);
FilterHolder secondFilter = new FilterHolder(MySecondFilter.class);
(Continue reading)