users@jersey.java.net

[Jersey] Re: Problem with Request/response filters

From: Jose Antonio Illescas Del Olmo <jantonio.illescas_at_rbcdexia-is.es>
Date: Fri, 12 Aug 2011 16:39:01 +0200

I see that ContainerResponseFilters must by one unique init-param join
class names with ";"

   after join my classes same error: filters don't intercepts nothing

On 12/08/2011 12:16, Jose Antonio Illescas Del Olmo wrote:
> I trying custom handlers with filters but not works: never execute
> filter code, I checking with:
>
> · custom response filter: OutputResponseFilter
> · logging request/response filter: LoggingFilter
>
> This is my web.xml configuration (and I use Guice):
>
> <filter>
> <filter-name>GuiceFilter</filter-name>
> <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
> </filter>
>
> <filter-mapping>
> <filter-name>GuiceFilter</filter-name>
> <servlet-name>JerseyServlet</servlet-name>
> <dispatcher>REQUEST</dispatcher>
> <dispatcher>ERROR</dispatcher>
> <dispatcher>INCLUDE</dispatcher>
> <dispatcher>FORWARD</dispatcher>
> </filter-mapping>
>
> <servlet>
> <servlet-name>JerseyServlet</servlet-name>
> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
>
> <init-param>
> <param-name>com.sun.jersey.config.property.packages</param-name>
> <param-value>mypackage</param-value> <!-- ';' separated packages -->
> </init-param>
> <init-param>
> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>
> <param-value>mypackage.OutputResponseFilter</param-value>
> </init-param>
> <init-param>
> <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
> <init-param>
> <param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
>
> <param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
>
> </init-param>
Now, I have single
"com.sun.jersey.spi.container.ContainerResponseFilters" as:

<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>

<param-value>com.sun.jersey.api.container.filter.*LoggingFilter*;mypackage.*OutputResponseFilter*</param-value>

</init-param>


> <load-on-startup>1</load-on-startup>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>JerseyServlet</servlet-name>
> <url-pattern>/rest/*</url-pattern>
> </servlet-mapping>
>
>