Compression filter for use with JSDK 2.3. The filter in this package can compress resources served by the servlet engine using GZip. Compression can reduce the size of Dataview data streams by 93%, drastically improving the network component of HTTP response performance. Compression is only performed for user agents that support GZip.

To use, add the following to the war file (make sure the sequence of elements is consistent with the war DTD):

    <filter>
      <filter-name>compressionFilter</filter-name>
      <filter-class>CompressionFilter</filter-class>
      <init-param>
        <param-name>compressionThreshold</param-name>
        <param-value>20000</param-value>
      </init-param>
    </filter>

    <filter-mapping>
      <filter-name>compressionFilter</filter-name>
      <url-pattern>/*</url-pattern>
    </filter-mapping>

OR

    <filter-mapping>
      <filter-name>compressionFilter</filter-name>
      <servlet-name>SomeServlet</servlet-name>
    </filter-mapping>
    
    

The compressionThreshold parameter is the minimum number of bytes in the output before the output will be compressed.

The <url-pattern> element above causes output from all resources served by the servlet engine to be GZip compressed for any user agent that supports GZip. In most cases, the <servlet-name> element is preferred because it is more specific.

Http stream compression should be restricted to file types that benefit from compression, such as (large) text files. Care should be taken to exclude images from compression, since most image formats are already compressed.

Code in this package was adapted from code originally written by Amy Roh as a Tomcat example and modified by Jason Hunter. It is distributed under the Apache software license.