users@jersey.java.net

Re: [Jersey] Using ContainerResponseFilters

From: Martin Matula <martin.matula_at_oracle.com>
Date: Mon, 27 Sep 2010 13:20:45 +0200

On Sep 23, 2010, at 1:15 AM, Marsh Eric wrote:

> Well, really not so much. I'd already found it and I'm not seeing
> where (in what file) to register the filters. Is that in web.xml?

Yes.

> I went to the LoggingFilter java doc and tried to click through to
> the com.sun.jersey.api.container.filter link to try to learn more
> about the base class but the link is dead.

Weird - looks like a bug in the default javadoc doclet.

> At this point I don't understand how to associate the filter with a
> particular URL or even how to write the filter. Is it essentially a
> standard servlet filter?

ContainerResponseFilter is not a standard servlet filter.
ContainerResponseFilter is not associated with a URL - i.e. it gets
called for each response and you need to do the URL matching yourself
in the filter method to decide if the filter should do anything or not.
You can check this one out as an example:
https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/contribs/jersey-oauth/oauth-server/src/main/java/com/sun/jersey/oauth/server/api/OAuthServerFilter.java?rev=4130&view=markup
Martin