com.opensymphony.oscache.web.filter
Class CacheFilter

java.lang.Object
  extended bycom.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.4.2.2 $
Author:
Serge Knystautas, Mike Cannon-Brookes

Field Summary
static java.lang.String HEADER_ACCEPT_ENCODING
           
static java.lang.String HEADER_CACHE_CONTROL
           
static java.lang.String HEADER_CONTENT_ENCODING
           
static java.lang.String HEADER_CONTENT_TYPE
           
static java.lang.String HEADER_EXPIRES
           
static java.lang.String HEADER_IF_MODIFIED_SINCE
           
static java.lang.String HEADER_LAST_MODIFIED
           
 
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
 

Field Detail

HEADER_LAST_MODIFIED

public static final java.lang.String HEADER_LAST_MODIFIED
See Also:
Constant Field Values

HEADER_CONTENT_TYPE

public static final java.lang.String HEADER_CONTENT_TYPE
See Also:
Constant Field Values

HEADER_CONTENT_ENCODING

public static final java.lang.String HEADER_CONTENT_ENCODING
See Also:
Constant Field Values

HEADER_EXPIRES

public static final java.lang.String HEADER_EXPIRES
See Also:
Constant Field Values

HEADER_IF_MODIFIED_SINCE

public static final java.lang.String HEADER_IF_MODIFIED_SINCE
See Also:
Constant Field Values

HEADER_CACHE_CONTROL

public static final java.lang.String HEADER_CACHE_CONTROL
See Also:
Constant Field Values

HEADER_ACCEPT_ENCODING

public static final java.lang.String HEADER_ACCEPT_ENCODING
See Also:
Constant Field Values
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:


See www.opensymphony.com for more information.