|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rakeshv.filters.FilterAdapter
org.rakeshv.filters.CompressionFilter
public class CompressionFilter
A Filter class that is used to compress the response
to a client request. The filter is activated only if the client
specified the Accept-Encoding, or the
TE HTTP headers.
The following shows ways in which you can enable the filters in your web application configuration file (WEB-INF/web.xml):
<filter>
<filter-name>compressionFilter</filter-name>
<filter-class>org.rakeshv.filters.CompressionFilter</filter-class>
<description>A servlet filter that supports Gzip, Deflate and ZIP compressed responses.</description>
</filter>
<filter-mapping>
<filter-name>compressionFilter</filter-name>
<servlet-name>myServlet</servlet-name>
</filter-mapping>
<filter-mapping>
<filter-name>compressionFilter</filter-name>
<url-pattern>/docs/*</url-pattern>
</filter-mapping>
© Copyright 2003, Rakesh Vidyadharan
| Field Summary | |
|---|---|
static int |
DEFLATE_COMPRESSION
A constant that is used to denote that deflate
compression is to be used. |
private javax.servlet.FilterConfig |
filterConfig
A reference to the Servlet container's Filter configuration. |
static int |
GZIP_COMPRESSION
A constant that is used to denote that gzip
compression is to be used. |
static int |
ZIP_COMPRESSION
A constant that is used to denote that zip
compression is to be used. |
| Constructor Summary | |
|---|---|
CompressionFilter()
|
|
| Method Summary | |
|---|---|
void |
doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
Check the Accept-Encoding and
accept-encoding HTTP headers, and if either of them
specified the accepted compression methods (those supported by
the java.util.zip classes), then the response is compressed using
the desired compression algorithm. |
| Methods inherited from class org.rakeshv.filters.FilterAdapter |
|---|
destroy, init, setFilterConfig |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFLATE_COMPRESSION
deflate
compression is to be used.
public static final int ZIP_COMPRESSION
zip
compression is to be used.
public static final int GZIP_COMPRESSION
gzip
compression is to be used.
private javax.servlet.FilterConfig filterConfig
| Constructor Detail |
|---|
public CompressionFilter()
| Method Detail |
|---|
public void doFilter(javax.servlet.ServletRequest request,
javax.servlet.ServletResponse response,
javax.servlet.FilterChain chain)
throws java.io.IOException,
javax.servlet.ServletException
Accept-Encoding and
accept-encoding HTTP headers, and if either of them
specified the accepted compression methods (those supported by
the java.util.zip classes), then the response is compressed using
the desired compression algorithm. If multiple algorithms were
specified, then one of the specified algorithms will be used.
The exact algorithm that will be used is in the order specified:
If the special * value is used to specify the
compression to use, Deflate compression will be used.
Note: This method does an implicit call to CompressionResponseWrapper.finish() if the response if being
compressed. Other servlets down the chain do not need to
worry about finishing the compression stream.
doFilter in interface javax.servlet.FilterdoFilter in class FilterAdapterjava.io.IOException - - If exceptions are encountered while
applying the filter.
javax.servlet.ServletException - - If exceptions are encountered while
interacting with the request or response objects.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||