Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mortbay.servlet
Class GzipFilter

    java.lang.Object
      org.mortbay.servlet.UserAgentFilter
          org.mortbay.servlet.GzipFilter

All Implemented Interfaces:
  Filter

Direct Known Subclasses:
  IncludableGzipFilter

    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 coma 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 `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

Nested Class Summary
`class` | `GzipFilter.GZIPResponseWrapper`
`static class` | `GzipFilter.GzipStream`

Field Summary
`protected int` | `_bufferSize`
`protected Set` | `_excluded`
`protected Set` | `_mimeTypes`
`protected int` | `_minGzipSize`

Constructor Summary
`GzipFilter()`

Method Summary
`void` | `destroy()`
`void` | `doFilter(ServletRequest req, ServletResponse res, FilterChain chain)`
`void` | `init(FilterConfig filterConfig)`
`protected GzipFilter.GZIPResponseWrapper` | `newGZIPResponseWrapper(HttpServletRequest request, HttpServletResponse response)`

Methods inherited from class org.mortbay.servlet.UserAgentFilter
`getUserAgent, getUserAgent`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _mimeTypes

    protected Set _mimeTypes

### _bufferSize

    protected int _bufferSize

### _minGzipSize

    protected int _minGzipSize

### _excluded

    protected Set _excluded

Constructor Detail

### GzipFilter

    public GzipFilter()

Method Detail

### 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)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1995-2008 Mort Bay Consulting. All Rights Reserved.