org.ibisph.filter.announcement
Class Filter
java.lang.Object
org.ibisph.filter.AbstractPathPatternFilter
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:
- Keep track of user's IP address and show "x" time. Each time they
hit the site could keep a counter for their IP. If they respond to
not see anymore then simply set the counter to the max.
-
Could simply implement in the index.html but this doesn't cover
those users who have book-marked specific pages as they would never
see it.
Filter Init Params:
| PARAMETER NAME | INIT-PARAM DESCRIPTION |
| _URIPatternFilter | Standard _URIPatternFilter "init-param"s |
| RedirectTo.URL | URL 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
|
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
alreadyShownCookieName
protected java.lang.String alreadyShownCookieName
alreadyShownCookieValue
protected java.lang.String alreadyShownCookieValue
redirectURL
protected java.lang.String redirectURL
Filter
public Filter()
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