org.ibisph.filter.announcement
Class Filter

java.lang.Object
  extended by org.ibisph.filter.AbstractPathPatternFilter
      extended by org.ibisph.filter.announcement.Filter
All Implemented Interfaces:
javax.servlet.Filter

public class Filter
extends AbstractPathPatternFilter

Provides ability to catch an initial request and redirect the user to an announcement type page.

IMPORTANT NOTE: This feature is not a good solution to use for the future as it messes up web crawlers from being able to hit and index the site. This is because it will redirect them to the announcement because the crawler will not have the approp cookie set!!! Solutions:

Filter Init Params:
PARAMETER NAMEINIT-PARAM DESCRIPTION
_URIPatternFilterStandard _URIPatternFilter "init-param"s
RedirectTo.URLURL to redirect the new, incoming request to.
AlreadyShown.CookieName Name of the cookie that is stored on the user's computer to be checked to see if the user has seen this page or not.
AlreadyShown.CookieValue Cookie value that controls if the page has been shown. If not the user's cookie value matches this value then the redirection does take place. If the cookie doesn't match then the user is redirected.

Author:
Garth Braithwaite, STG

Nested Class Summary
 
Nested classes/interfaces inherited from class org.ibisph.filter.AbstractPathPatternFilter
AbstractPathPatternFilter.PathPattern
 
Field Summary
protected  java.lang.String alreadyShownCookieName
           
protected  java.lang.String alreadyShownCookieValue
           
protected  java.lang.String redirectURL
           
 
Fields inherited from class org.ibisph.filter.AbstractPathPatternFilter
LIST_SEPERATOR_PARAM_NAME, MATCH_LIST_PARAM_NAME, MATCH_TYPE_PARAM_NAME, pathPattern, REQUEST_PATH_TYPE_PARAM_NAME
 
Constructor Summary
Filter()
           
 
Method Summary
 void destroy()
          Required filter method
 void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)
          Main filter method that checks to the already shown cookie name/value.
 void init(javax.servlet.FilterConfig filterConfig)
          Sets the filter's control properties via the init-parameters (located in the application's deployment web.xml file).
 
Methods inherited from class org.ibisph.filter.AbstractPathPatternFilter
getInitParameterValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alreadyShownCookieName

protected java.lang.String alreadyShownCookieName

alreadyShownCookieValue

protected java.lang.String alreadyShownCookieValue

redirectURL

protected java.lang.String redirectURL
Constructor Detail

Filter

public Filter()
Method Detail

init

public void init(javax.servlet.FilterConfig filterConfig)
Sets the filter's control properties via the init-parameters (located in the application's deployment web.xml file).

Specified by:
init in interface javax.servlet.Filter
Overrides:
init in class AbstractPathPatternFilter
Parameters:
filterConfig - Contains the init parameters that contain the URL to redirect to, the "to show" cookie name and the associated cookie value.

doFilter

public void doFilter(javax.servlet.ServletRequest req,
                     javax.servlet.ServletResponse res,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Main filter method that checks to the already shown cookie name/value. If not set, then redirect to the specified URL. Otherwise let the request go through its normal course.

Parameters:
req - Original request.
res - Original response.
chain - Filter chain to call for normal, downstream filter/servlet request/response handling.
Throws:
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()
Required filter method

Specified by:
destroy in interface javax.servlet.Filter
Overrides:
destroy in class AbstractPathPatternFilter