users@jersey.java.net

Re: [Jersey] Gzip compression filter in 1.0?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 22 Oct 2008 10:01:28 +0200

On Oct 22, 2008, at 2:44 AM, saturon wrote:

> Hi there,
>
> What is the best way to make a resource produce compressed data?
> Somewhere I read compression filters are present in 1.0 (I am still
> using 0.8, would like to wait for netbeans plugin).
>

Jersey 1.0 is in NetBeans 6.5 RC [1] if you want to give it a try.

> Is this correct? And how would I use it?
>

In your web.xml add the following init param:

           <init-param>
             <param-
name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
             <param-
value>com.sun.jersey.api.container.filter.GZIPContentEncodingFilter</
param-value>
         </init-param>

See JavaDoc here:

https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/api/jersey/com/sun/jersey/api/container/filter/GZIPContentEncodingFilter.html

https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/api/jersey/com/sun/jersey/api/core/ResourceConfig.html
#PROPERTY_CONTAINER_RESPONSE_FILTERS

https://jersey.dev.java.net/source/browse/*checkout*/jersey/tags/jersey-1.0/api/jersey/com/sun/jersey/api/core/ResourceConfig.html
#PROPERTY_CONTAINER_REQUEST_FILTERS


Note that the client must include an Accept-Encoding head that
contains a value of "gzip".

Paul.

[1] http://download.netbeans.org/netbeans/6.5/rc/