|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.extras.filter.CompressionFilter
Provides a GZIP compression Filter to compress HTML ServletResponse content. The content will only be compressed if it is bigger than a configurable threshold. The default threshold is 2048 bytes.
To configure your application to GZIP compress HTML content include the click-extras.jar in you application and add the following filter elements to your /WEB-INF/web.xml file:<filter> <filter-name>compression-filter</filter-name> <filter-class>net.sf.click.extras.filter.CompressionFilter</filter-class> </filter> <filter-mapping> <filter-name>compression-filter</filter-name> <servlet-name>click-servlet</servlet-name> </filter-mapping> <servlet> <servlet-name>click-servlet</servlet-name> ..This filter will automaitically set the configured click.xml charset as the requests character encoding. This package is derived from the Jakarta Tomcat examples compression filter and is distributed in Click Extras for convenience.
Field Summary | |
protected int |
compressionThreshold
The threshold number to compress, default value is 2048 bytes. |
protected ConfigService |
configService
The application configuration service. |
protected boolean |
configured
The fitler has been configured flag. |
protected int |
minThreshold
Minimal reasonable threshold, 2048 bytes. |
Constructor Summary | |
CompressionFilter()
|
Method Summary | |
void |
destroy()
Take this filter out of service. |
void |
doFilter(ServletRequest request,
ServletResponse response,
FilterChain chain)
The doFilter method of the Filter is called by the container
each time a request/response pair is passed through the chain due
to a client request for a resource at the end of the chain. |
protected ConfigService |
getConfigService()
Return the application configuration service. |
FilterConfig |
getFilterConfig()
Return filter config. |
void |
init(FilterConfig filterConfig)
Place this filter into service. |
protected void |
loadConfiguration()
Load the filters configuration and set the configured flat to true. |
void |
setFilterConfig(FilterConfig filterConfig)
Set filter configuration. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected int minThreshold
protected int compressionThreshold
protected boolean configured
protected ConfigService configService
Constructor Detail |
public CompressionFilter()
Method Detail |
public void init(FilterConfig filterConfig)
init
in interface Filter
filterConfig
- The filter configuration objectpublic void destroy()
destroy
in interface Filter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doFilter
method of the Filter is called by the container
each time a request/response pair is passed through the chain due
to a client request for a resource at the end of the chain.
The FilterChain passed into this method allows the Filter to pass on the
request and response to the next entity in the chain.
This method first examines the request to check whether the client support
compression.
It simply just pass the request and response if there is no support for
compression.
If the compression support is available, it creates a
CompressionServletResponseWrapper object which compresses the content and
modifies the header if the content length is big enough.
It then invokes the next entity in the chain using the FilterChain object
(chain.doFilter()
)
doFilter
in interface Filter
request
- the servlet requestresponse
- the servlet responsechain
- the filter chain
IOException
- if an I/O error occurs
ServletException
- if a servlet error occurspublic void setFilterConfig(FilterConfig filterConfig)
filterConfig
- the filter configuration objectpublic FilterConfig getFilterConfig()
protected ConfigService getConfigService()
protected void loadConfiguration()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |