org.ibisph.filter
Class SetCharacterEncodingFilter

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

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

Filter that simply sets the character encoding for a downstream/chained request. This allows for form character data to be processed as it was served to the browser (consistently) when accessed via a request.getParameter() type call. This typically isn't a problem for those server enviros that have one or two apps and can set the character encoding to the match the app. It can be an issue if the app server is set for some other character set and this app is different. Since ISO-8859-1 is a subset of UTF-8 it shouldn't be an issue but this filter can be used to set explicitly just in case.

Author:
Garth Braithwaite, STG

Field Summary
protected  java.lang.String characterEncoding
           
 
Constructor Summary
SetCharacterEncodingFilter()
           
 
Method Summary
 void destroy()
          Required method - Does NOT do anything.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain)
          Method that actually sets the downstream request's character encoding to be used.
 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).
 void setCharacterEncoding(java.lang.String characterEncoding)
          Property setter for the character encoding to be used for posts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

characterEncoding

protected java.lang.String characterEncoding
Constructor Detail

SetCharacterEncodingFilter

public SetCharacterEncodingFilter()
Method Detail

setCharacterEncoding

public void setCharacterEncoding(java.lang.String characterEncoding)
Property setter for the character encoding to be used for posts.

Parameters:
characterEncoding - Value used for downstream code when request's request's parameter value is asked for. This value controls how a parameter is decoded.

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException
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
Parameters:
filterConfig - allows the init method to access filter and servlet objects.
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain filterChain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Method that actually sets the downstream request's character encoding to be used.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()
Required method - Does NOT do anything.

Specified by:
destroy in interface javax.servlet.Filter