javawebparts.filter
Class CompressionFilter

java.lang.Object
  |
  +--javawebparts.filter.CompressionFilter
All Implemented Interfaces:
javax.servlet.Filter

public class CompressionFilter
extends java.lang.Object
implements javax.servlet.Filter

This filter allows for compressing the response from the server. It allows for including or excluding paths from filter functionality. It also allows for defining what type of compression should be used, if supported by the client, and in what order.

Init parameters are:


Example configuration in web.xml:

<filter>
  <filter-name>CompressionFilter</filter-name>
  <filter-class>javawebparts.filter. CompressionFilter</filter-class>
  <init-param>
    <param-name>pathSpec</param-name>
    <param-value>include</param-value>
  </init-param>
  <init-param>
    <param-name>pathList</param-name>
    <param-value>*‍/bigimage2.gif</ param-value>
  </init-param>
  <init-param>
    <param-name>compressType</param-name>
    <param-value>gzip_first</param-value>
  </init-param>
</filter>

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

Author:
Frank W. Zammetti.

Field Summary
private  java.lang.String compressType
          What type of oompression we want this filter to do.
private static org.apache.commons.logging.Log log
          Log instance.
private  java.util.ArrayList pathList
          List of paths for filter functionality determination.
private  java.lang.String pathSpec
          Whether pathList includes or excludes.
 
Constructor Summary
CompressionFilter()
           
 
Method Summary
 void destroy()
          Destroy.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain)
          Do filter's work.
 void init(javax.servlet.FilterConfig filterConfig)
          Initialize this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log instance.


pathSpec

private java.lang.String pathSpec
Whether pathList includes or excludes.


pathList

private java.util.ArrayList pathList
List of paths for filter functionality determination.


compressType

private java.lang.String compressType
What type of oompression we want this filter to do. Valid values are "gzip_only", "deflate_only", "gzip_first" and "deflate_first". If neither compression type is supported by the client, no compression is attempted. If the client supports both and this option is "gzip_first", GZip be used if it is supported, or Deflate if not, and the exact opposite is true when "deflate_first" is used. If set to "gzip_first" but only Deflate is supported, Deflate will be used, and vice-versa.

Constructor Detail

CompressionFilter

public CompressionFilter()
Method Detail

destroy

public void destroy()
Destroy.

Specified by:
destroy in interface javax.servlet.Filter

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Initialize this filter.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - The configuration information for this filter.
Throws:
javax.servlet.ServletException - ServletException.

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain filterChain)
              throws javax.servlet.ServletException,
                     java.io.IOException
Do filter's work.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - The current request object.
response - The current response object.
filterChain - The current filter chain.
Throws:
javax.servlet.ServletException - ServletException.
java.io.IOException - IOException.


Copyright 2005 Frank W. Zammetti