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<Pattern> |
_excludedAgentPatterns |
protected Set<String> |
_excludedAgents |
protected Set<Pattern> |
_excludedPathPatterns |
protected Set<String> |
_excludedPaths |
protected Set<String> |
_mimeTypes |
protected int |
_minGzipSize |
Constructor and Description |
---|
GzipFilter() |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
void |
doFilter(ServletRequest req,
ServletResponse res,
FilterChain chain) |
void |
init(FilterConfig filterConfig) |
protected GzipResponseWrapper |
newGzipResponseWrapper(HttpServletRequest request,
HttpServletResponse response)
Allows derived implementations to replace ResponseWrapper implementation.
|
protected PrintWriter |
newWriter(OutputStream out,
String encoding)
Allows derived implementations to replace PrintWriter implementation.
|
getUserAgent, getUserAgent
public void init(FilterConfig filterConfig) throws ServletException
init
in interface Filter
init
in class UserAgentFilter
ServletException
UserAgentFilter.init(javax.servlet.FilterConfig)
public void destroy()
destroy
in interface Filter
destroy
in class UserAgentFilter
UserAgentFilter.destroy()
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException
doFilter
in interface Filter
doFilter
in class UserAgentFilter
IOException
ServletException
UserAgentFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
protected GzipResponseWrapper newGzipResponseWrapper(HttpServletRequest request, HttpServletResponse response)
request
- the requestresponse
- the responseprotected PrintWriter newWriter(OutputStream out, String encoding) throws UnsupportedEncodingException
out
- the outencoding
- the encodingUnsupportedEncodingException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.