net.sf.ehcache.constructs.web.filter
Class SimplePageCachingFilterWithBlankPageProblem

java.lang.Object
  extended by net.sf.ehcache.constructs.web.filter.Filter
      extended by net.sf.ehcache.constructs.web.filter.CachingFilter
          extended by net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
              extended by net.sf.ehcache.constructs.web.filter.SimplePageCachingFilterWithBlankPageProblem
All Implemented Interfaces:
javax.servlet.Filter

public class SimplePageCachingFilterWithBlankPageProblem
extends SimplePageCachingFilter

This implementation only writes the response when it is not committed. This is half right. In the wild it can cause the dreaded blank page problem.

Another half right solution is to write the response. The problem then is, if the response is gzipped, the body might be gzipped but the headers won't show it. The result will be yet another blank page in Internet Explorer.

The correct thing to do is to throw an exception.

Version:
$Id: SimplePageCachingFilterWithBlankPageProblem.java 796 2008-10-09 02:39:03Z gregluck $
Author:
Greg Luck
See Also:
SimplePageCachingFilter

Field Summary
static java.lang.String NAME
          The name of the filter.
 
Fields inherited from class net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
DEFAULT_CACHE_NAME
 
Fields inherited from class net.sf.ehcache.constructs.web.filter.CachingFilter
blockingCache, cacheName
 
Fields inherited from class net.sf.ehcache.constructs.web.filter.Filter
exceptionsToLogDifferently, filterConfig, NO_FILTER, suppressStackTraces
 
Constructor Summary
SimplePageCachingFilterWithBlankPageProblem()
           
 
Method Summary
protected  void doFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          Performs the filtering for a request.
 
Methods inherited from class net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter
calculateKey, getCacheManager, getCacheName
 
Methods inherited from class net.sf.ehcache.constructs.web.filter.CachingFilter
buildPage, buildPageInfo, checkNoReentry, doDestroy, doInit, setCacheNameIfAnyConfigured, setContentType, setCookies, setHeaders, setStatus, writeContent, writeResponse
 
Methods inherited from class net.sf.ehcache.constructs.web.filter.Filter
acceptsEncoding, acceptsGzipEncoding, destroy, doFilter, filterNotDisabled, getFilterConfig, init, logRequestHeaders, processInitParams
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final java.lang.String NAME
The name of the filter. This should match a cache name in ehcache.xml

See Also:
Constant Field Values
Constructor Detail

SimplePageCachingFilterWithBlankPageProblem

public SimplePageCachingFilterWithBlankPageProblem()
Method Detail

doFilter

protected void doFilter(javax.servlet.http.HttpServletRequest request,
                        javax.servlet.http.HttpServletResponse response,
                        javax.servlet.FilterChain chain)
                 throws java.lang.Exception
Performs the filtering for a request. This method caches based responses keyed by CachingFilter.calculateKey(javax.servlet.http.HttpServletRequest)

By default this method will queue requests requesting the page response for a given key until the first thread in the queue has completed. The request which occurs when the page expires incurs the cost of waiting for the downstream processing to return the respone.

The maximum time to wait can be configured by setting setTimeoutMillis on the underlying BlockingCache.

Overrides:
doFilter in class CachingFilter
Throws:
AlreadyGzippedException - if a double gzip is attempted
AlreadyCommittedException - if the response was committed on the way in or the on the way back
FilterNonReentrantException - if an attempt is made to reenter this filter in the same request.
net.sf.ehcache.constructs.blocking.LockTimeoutException - if this request is waiting on another that is populating the cache entry and timeouts while waiting. Only occurs if the BlockingCache has a timeout set.
java.lang.Exception - for all other exceptions. They will be caught and logged in Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)


Copyright ? 2003-2010 Terracotta, Inc.. All Rights Reserved.