org.mortbay.servlet
Class GzipFilter
java.lang.Object
org.mortbay.servlet.UserAgentFilter
org.mortbay.servlet.GzipFilter
- All Implemented Interfaces:
- Filter
public class GzipFilter
- extends UserAgentFilter
GZIP Filter
This filter will gzip the content of a response iff:
- The filter is mapped to a matching path
- The response status code is >=200 and <300
- The content length is unknown or more than the
minGzipSize initParameter or the minGzipSize is 0(default)
- The content-type is in the comma separated list of mimeTypes set in the
mimeTypes initParameter or
if no mimeTypes are defined the content-type is not "application/gzip"
- No content-encoding is specified by the resource
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 org.mortbay.jetty.servlet.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.
- Author:
- gregw
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_mimeTypes
protected Set _mimeTypes
_bufferSize
protected int _bufferSize
_minGzipSize
protected int _minGzipSize
_excluded
protected Set _excluded
GzipFilter
public GzipFilter()
init
public void init(FilterConfig filterConfig)
throws ServletException
- Specified by:
init in interface Filter- Overrides:
init in class UserAgentFilter
- Throws:
ServletException
destroy
public void destroy()
- Specified by:
destroy in interface Filter- Overrides:
destroy in class UserAgentFilter
doFilter
public void doFilter(ServletRequest req,
ServletResponse res,
FilterChain chain)
throws IOException,
ServletException
- Specified by:
doFilter in interface Filter- Overrides:
doFilter in class UserAgentFilter
- Throws:
IOException
ServletException
newGZIPResponseWrapper
protected GzipFilter.GZIPResponseWrapper newGZIPResponseWrapper(HttpServletRequest request,
HttpServletResponse response)
newWriter
protected PrintWriter newWriter(OutputStream out,
String encoding)
throws UnsupportedEncodingException
- Throws:
UnsupportedEncodingException
Copyright © 2009 Mortbay Consulting Pty. Ltd. All Rights Reserved.