jodd.servlet.filter
Class GzipFilter

java.lang.Object
  extended by jodd.servlet.filter.GzipFilter
All Implemented Interfaces:
javax.servlet.Filter

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

Compresses output with gzip, for browsers that supports it.

Configuration is based on the following initialization parameters:


Field Summary
protected  java.lang.String[] excludes
           
protected  java.lang.String[] matches
           
protected  int threshold
          The threshold number to compress, (0 == no compression).
protected  boolean wildcards
           
 
Constructor Summary
GzipFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          If browser supports gzip, sets the Content-Encoding response header and invoke resource with a wrapped response that collects all the output.
 void init(javax.servlet.FilterConfig config)
          Filter initialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threshold

protected int threshold
The threshold number to compress, (0 == no compression).


matches

protected java.lang.String[] matches

excludes

protected java.lang.String[] excludes

wildcards

protected boolean wildcards
Constructor Detail

GzipFilter

public GzipFilter()
Method Detail

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws javax.servlet.ServletException,
                     java.io.IOException
If browser supports gzip, sets the Content-Encoding response header and invoke resource with a wrapped response that collects all the output. Extracts the output and write it into a gzipped byte array. Finally, write that array to the client's output stream.

If browser does not support gzip, invokes resource normally.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException
java.io.IOException

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Filter initialization.

Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter


Copyright © 2003-2012 Jodd Team