|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjodd.servlet.filters.GzipFilter
Compresses output with gzip, for browsers that supports it.
Configuration of this filter is based on the following initialization parameters:
This filter has been build and extend from Tomcats example.
Technical notes: i have found that this is the only way how gzip filter can be build. The first idea that comes to mind is to wrap response to some character-based wrapper, and then to gzip it to the output. This works fine except when forwarding is used: forwarded page is gzipped, but response header is no more there! I have not an idea how to fix this except from this approach presented in Tomcat.
Field Summary | |
protected int |
threshold
The threshold number to compress, (0 == no compression). |
protected java.lang.String |
uriExclude
Comma separated string patterns to be excluded in the request URI if founded by match. |
protected java.lang.String |
uriMatch
Comma separated string patterns to be found in the request URI |
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, set the Content-Encoding response header and invoke resource with a wrapped response that collects all the output. |
protected javax.servlet.FilterConfig |
getFilterConfig()
|
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 |
protected java.lang.String uriMatch
protected java.lang.String uriExclude
protected int threshold
Constructor Detail |
public GzipFilter()
Method Detail |
protected javax.servlet.FilterConfig getFilterConfig()
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws javax.servlet.ServletException, java.io.IOException
doFilter
in interface javax.servlet.Filter
request
- response
- chain
-
javax.servlet.ServletException
java.io.IOException
public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException
init
in interface javax.servlet.Filter
config
-
javax.servlet.ServletException
public void destroy()
destroy
in interface javax.servlet.Filter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |