javawebparts.filter
Class ParameterMungerFilter

java.lang.Object
  |
  +--javawebparts.filter.ParameterMungerFilter
All Implemented Interfaces:
javax.servlet.Filter

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

This filter can perform various operations on incoming parameters. It allows for including or excluding paths from filter functionality. It also allows for performing one or more defined operations on every parameter received.

Init parameters are:


Example configuration in web.xml:

<filter>
  <filter-name>ParameterMungerFilter</filter-name>
  <filter-class>javawebparts.filter. ParameterMungerFilter</filter-class>
  <init-param>
    <param-name>pathSpec</param-name>
    <param-value>include</param-value>
  </init-param>
  <init-param>
    <param-name>pathList</param-name>
    <param-value>*‍/parameterMungerFilterTest </param-value>
  </init-param>
  <init-param>
    <param-name>functionList</param-name>
    <param-value>trim,ucase,reverse</ param-value>
  </init-param>
</filter>

<filter-mapping>
  <filter-name>ParameterMungerFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

Author:
Frank W. Zammetti.

Field Summary
private static java.lang.String FUNCTION_LCASE
          Constant for function lcase function.
private static java.lang.String FUNCTION_REVERSE
          Constant for function reverse function.
private static java.lang.String FUNCTION_TRIM
          Constant for function trim function.
private static java.lang.String FUNCTION_UCASE
          Constant for function ucase function.
private  java.util.ArrayList functionList
          The list of functions to be performed.
private static org.apache.commons.logging.Log log
          Log instance.
private  java.util.ArrayList pathList
          List of paths for filter functionality determination.
private  java.lang.String pathSpec
          Whether pathList includes or excludes.
 
Constructor Summary
ParameterMungerFilter()
           
 
Method Summary
 void destroy()
          Destroy.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain)
          Do filter's work.
 void init(javax.servlet.FilterConfig filterConfig)
          Initialize this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Log instance.


FUNCTION_TRIM

private static final java.lang.String FUNCTION_TRIM
Constant for function trim function.

See Also:
Constant Field Values

FUNCTION_LCASE

private static final java.lang.String FUNCTION_LCASE
Constant for function lcase function.

See Also:
Constant Field Values

FUNCTION_UCASE

private static final java.lang.String FUNCTION_UCASE
Constant for function ucase function.

See Also:
Constant Field Values

FUNCTION_REVERSE

private static final java.lang.String FUNCTION_REVERSE
Constant for function reverse function.

See Also:
Constant Field Values

pathSpec

private java.lang.String pathSpec
Whether pathList includes or excludes.


pathList

private java.util.ArrayList pathList
List of paths for filter functionality determination.


functionList

private java.util.ArrayList functionList
The list of functions to be performed.

Constructor Detail

ParameterMungerFilter

public ParameterMungerFilter()
Method Detail

destroy

public void destroy()
Destroy.

Specified by:
destroy in interface javax.servlet.Filter

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
Initialize this filter.

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - The configuration information for this filter.
Throws:
javax.servlet.ServletException - ServletException.

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain filterChain)
              throws javax.servlet.ServletException,
                     java.io.IOException
Do filter's work.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - The current request object.
response - The current response object.
filterChain - The current filter chain.
Throws:
javax.servlet.ServletException - ServletException.
java.io.IOException - IOException.


Copyright © 2005 Frank W. Zammetti