org.chwf.servlet.filter
Class FilterSupport

java.lang.Object
  |
  +--org.chwf.servlet.filter.FilterSupport
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
EncryptionFilter, InitFilter, InvokerFilter, RedirectFilter, ResourceMapper, SecurityFilter, TemplateFilter

public class FilterSupport
extends java.lang.Object
implements javax.servlet.Filter

Filter superclass with dummy methods to simplify filter creation. It based on the same principle as the TagSupport classes.

Author:
Paul Strack

Constructor Summary
FilterSupport()
           
 
Method Summary
 void destroy()
          Called by the web container to indicate to a filter that it is being taken out of service.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.
 void doHttpFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          A doFilter() method for HTTP filters (the norm).
protected  javax.servlet.FilterConfig getConfig()
          Get FilterConfig.
 void init(javax.servlet.FilterConfig config)
          Called by the web container to indicate to a filter that it is being placed into service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilterSupport

public FilterSupport()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Called by the web container to indicate to a filter that it is being placed into service. The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work.

The dummy method stores the config in an instance variable.

Specified by:
init in interface javax.servlet.Filter
Parameters:
config - The filter config.
Throws:
javax.servlet.ServletException - Will prevent the filter from being initialized.

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.

The dummy method delegates to doHttpFilter()

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - The request.
response - The response.
chain - The filter chain.
Throws:
javax.servlet.ServletException - For servlet errors.
java.io.IOException - For I/O errors.

doHttpFilter

public void doHttpFilter(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         javax.servlet.FilterChain chain)
                  throws java.io.IOException,
                         javax.servlet.ServletException
A doFilter() method for HTTP filters (the norm).

The dummy method invokes the next filter in the chain. This method should be overridden by subclasses.

Parameters:
request - The request.
response - The response.
chain - The filter chain.
Throws:
javax.servlet.ServletException - For servlet errors.
java.io.IOException - For I/O errors.

destroy

public void destroy()
Called by the web container to indicate to a filter that it is being taken out of service. This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.

The dummy method does nothing.

Specified by:
destroy in interface javax.servlet.Filter

getConfig

protected javax.servlet.FilterConfig getConfig()
Get FilterConfig.
Returns:
The FilterConfig.


Copyright © 2002-2004, Paul Strack. All Rights Reserved.