Package com.twelvemonkeys.servlet.cache
Class CacheFilter
- java.lang.Object
-
- com.twelvemonkeys.servlet.GenericFilter
-
- com.twelvemonkeys.servlet.cache.CacheFilter
-
- All Implemented Interfaces:
java.io.Serializable
,javax.servlet.Filter
,javax.servlet.FilterConfig
public class CacheFilter extends GenericFilter
A Filter that provides response caching, for HTTPGET
requests.Originally based on ideas and code found in the ONJava article Two Servlet Filters Every Web Application Should Have by Jayson Falkner.
- Version:
- $Id: CacheFilter.java#4 $
- Author:
- Jayson Falkner, Harald Kuhr, last modified by $Author: haku $
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.twelvemonkeys.servlet.GenericFilter
oncePerRequest
-
-
Constructor Summary
Constructors Constructor Description CacheFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Called by the web container to indicate to a filter that it is being taken out of service.protected void
doFilterImpl(javax.servlet.ServletRequest pRequest, javax.servlet.ServletResponse pResponse, javax.servlet.FilterChain pChain)
Invoked once, or each time a request/response pair is passed through the chain, depending on theGenericFilter.oncePerRequest
member variable.void
init()
Initializes the filter-
Methods inherited from class com.twelvemonkeys.servlet.GenericFilter
doFilter, getFilterConfig, getFilterName, getInitParameter, getInitParameterNames, getServletContext, init, log, log, setFilterConfig, setOncePerRequest
-
-
-
-
Method Detail
-
init
public void init() throws javax.servlet.ServletException
Initializes the filter- Overrides:
init
in classGenericFilter
- Throws:
javax.servlet.ServletException
- See Also:
GenericFilter.init(FilterConfig)
-
destroy
public void destroy()
Description copied from class:GenericFilter
Called by the web container to indicate to a filter that it is being taken out of service.- Specified by:
destroy
in interfacejavax.servlet.Filter
- Overrides:
destroy
in classGenericFilter
- See Also:
Filter.destroy()
-
doFilterImpl
protected void doFilterImpl(javax.servlet.ServletRequest pRequest, javax.servlet.ServletResponse pResponse, javax.servlet.FilterChain pChain) throws java.io.IOException, javax.servlet.ServletException
Description copied from class:GenericFilter
Invoked once, or each time a request/response pair is passed through the chain, depending on theGenericFilter.oncePerRequest
member variable.- Specified by:
doFilterImpl
in classGenericFilter
- Parameters:
pRequest
- the servlet requestpResponse
- the servlet responsepChain
- the filter chain- Throws:
java.io.IOException
- if an I/O error occursjavax.servlet.ServletException
- if an exception occurs during the filter process- See Also:
GenericFilter.oncePerRequest
,doFilter
,Filter.doFilter
-
-