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

## com.opensymphony.oscache.web.filter
Class CacheFilter

    java.lang.Object
      com.opensymphony.oscache.web.filter.CacheFilter

All Implemented Interfaces:
  javax.servlet.Filter

public class CacheFilter
extends java.lang.Object
implements javax.servlet.Filter

CacheFilter is a filter that allows for server-side caching of post-processed servlet content.

It also gives great programatic control over refreshing, flushing and updating the cache.

Version:
  $Revision: 1.2 $
Author:
  Serge Knystautas, Mike Cannon-Brookes

Constructor Summary
`CacheFilter()`

Method Summary
`void` | `destroy()` Filter clean-up
`void` | `doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)` The doFilter call caches the response by wrapping the `HttpServletResponse` object so that the output stream can be caught.
`void` | `init(javax.servlet.FilterConfig filterConfig)` Initialize the filter.

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

Constructor Detail

### CacheFilter

    public CacheFilter()

Method Detail

### destroy

    public void destroy()

  Filter clean-up

  Specified by:
    `destroy` in interface `javax.servlet.Filter`

### doFilter

    public void doFilter(javax.servlet.ServletRequest request,
                         javax.servlet.ServletResponse response,
                         javax.servlet.FilterChain chain)
                  throws javax.servlet.ServletException,
                         java.io.IOException

  The doFilter call caches the response by wrapping the `HttpServletResponse` object so that the output stream can be caught. This works by splitting off the output stream into two with the `SplitServletOutputStream` class. One stream gets written out to the response as normal, the other is fed into a byte array inside a `ResponseContent` object.

  Specified by:
    `doFilter` in interface `javax.servlet.Filter`
  Parameters:
    `request` - The servlet request
    `response` - The servlet response
    `chain` - The filter chain
  Throws:
    `javax.servlet.ServletException` - IOException
    `java.io.IOException`

### init

    public void init(javax.servlet.FilterConfig filterConfig)

  Initialize the filter. This retrieves a `ServletCacheAdministrator` instance and configures the filter based on any initialization parameters.

  The supported initialization parameters are:

  - time - the default time (in seconds) to cache content for. The default value is 3600 seconds (one hour).
  - scope - the default scope to cache content in. Acceptable values are `application` (default), `session`, `request` and `page`.

  Specified by:
    `init` in interface `javax.servlet.Filter`
  Parameters:
    `filterConfig` - The filter configuration

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| See www.opensymphony.com for more information.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD