javawebparts.filter
Class CharacterEncodingFilter

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

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

This filter allows for setting the Content-Type header of a request to set the character encoding scheme. Because some browsers do not send the character encoding scheme in the Content-Type header, problems can arise when the server uses a default scheme to parse incoming request parameters. If the default scheme does not happen to match what the clients' default is, the parameters will be parsed incorrectly. Note that if the client did send an encoding scheme, this filter WILL NOT override it.

Init parameters are:


Example configuration in web.xml:

  <filter>
  <filter-name>CharacterEncodingFilter</filter-name>
  <filter-class>javawebparts.filter. CharacterEncodingFilter</filter-class>
  <init-param>
    <param-name>encodingScheme</param-name>
    <param-value>?????</param-value>
  </init-param>
</filter>

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

Author:
Frank W. Zammetti.

Field Summary
private  java.lang.String encodingScheme
          The encodingScheme read in from configuration.
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
CharacterEncodingFilter()
           
 
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.


pathSpec

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


pathList

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


encodingScheme

private java.lang.String encodingScheme
The encodingScheme read in from configuration.

Constructor Detail

CharacterEncodingFilter

public CharacterEncodingFilter()
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 java.io.IOException,
                     javax.servlet.ServletException
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