public class GzipFilter extends UserAgentFilter
minGzipSize initParameter or the minGzipSize is 0(default)mimeTypes initParameter or
if no mimeTypes are defined the content-type is not "application/gzip"
Compressing the content can greatly improve the network bandwidth usage, but at a cost of memory and
CPU cycles. If this filter is mapped for static content, then use of efficient direct NIO may be
prevented, thus use of the gzip mechanism of the DefaultServlet is
advised instead.
This filter extends UserAgentFilter and if the the initParameter excludedAgents
is set to a comma separated list of user agents, then these agents will be excluded from gzip content.
| Modifier and Type | Field and Description |
|---|---|
protected int |
_bufferSize |
protected Set<String> |
_excluded |
protected Set<String> |
_mimeTypes |
protected int |
_minGzipSize |
| Constructor and Description |
|---|
GzipFilter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain) |
void |
init(javax.servlet.FilterConfig filterConfig) |
protected GzipResponseWrapper |
newGzipResponseWrapper(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Allows derived implementations to replace ResponseWrapper implementation.
|
protected PrintWriter |
newWriter(OutputStream out,
String encoding)
Allows derived implementations to replace PrintWriter implementation.
|
getUserAgent, getUserAgentpublic void init(javax.servlet.FilterConfig filterConfig)
throws javax.servlet.ServletException
init in interface javax.servlet.Filterinit in class UserAgentFilterjavax.servlet.ServletExceptionUserAgentFilter.init(javax.servlet.FilterConfig)public void destroy()
destroy in interface javax.servlet.Filterdestroy in class UserAgentFilterUserAgentFilter.destroy()public void doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
doFilter in interface javax.servlet.FilterdoFilter in class UserAgentFilterIOExceptionjavax.servlet.ServletExceptionUserAgentFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)protected GzipResponseWrapper newGzipResponseWrapper(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request - the requestresponse - the responseprotected PrintWriter newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException
out - the outencoding - the encodingUnsupportedEncodingExceptionCopyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.