ChadDavis | 1 Jan 01:13 2010
Picon

[jetty-user] adding a filter programmatically

I couldn't find any documentation on how to programmatically add a
servlet filter.  Is there any?

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Greg Wilkins | 2 Jan 00:32 2010

Re: [jetty-user] adding a filter programmatically


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.

cheers

ChadDavis wrote:
> I couldn't find any documentation on how to programmatically add a
> servlet filter.  Is there any?
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 

---------------------------------------------------------------------
(Continue reading)

Philippe Marschall | 9 Jan 09:57 2010
Picon
Picon

Re: [jetty-user] adding a filter programmatically

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)


Gmane