org.itracker.web.filters
Class SetRequestCharacterEncoding

java.lang.Object
  extended by org.itracker.web.filters.SetRequestCharacterEncoding
All Implemented Interfaces:
javax.servlet.Filter

public class SetRequestCharacterEncoding
extends Object
implements javax.servlet.Filter

This class will set the chracter encoding of each request that uses the filter. It will use the encoding specifried in the init parameter, or if that is not present, fall back to a default value of UTF-8.


Field Summary
static String DEFAULT_ENCODING
           
 
Constructor Summary
SetRequestCharacterEncoding()
           
 
Method Summary
 void destroy()
          Reset the filter settings.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain)
          Set the character encoding in the request.
 String getEncoding()
          Returns the encoding of the request.
 javax.servlet.FilterConfig getFilterConfig()
           
 void init(javax.servlet.FilterConfig filterConfig)
          Initialize the filter.
 void setEncoding(String value)
          Sets the encoding of the request.
 void setFilterConfig(javax.servlet.FilterConfig filterConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values
Constructor Detail

SetRequestCharacterEncoding

public SetRequestCharacterEncoding()
Method Detail

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain filterChain)
              throws IOException,
                     javax.servlet.ServletException
Set the character encoding in the request.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - the current ServletRequest object
response - the current ServletResponse object
filterChain - the current FilterChain
Throws:
IOException - if any io error occurs
javax.servlet.ServletException - any other servlet error occurs

init

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

Specified by:
init in interface javax.servlet.Filter
Parameters:
filterConfig - the current filter configuration
Throws:
javax.servlet.ServletException

getEncoding

public String getEncoding()
Returns the encoding of the request.


setEncoding

public void setEncoding(String value)
Sets the encoding of the request.


destroy

public void destroy()
Reset the filter settings.

Specified by:
destroy in interface javax.servlet.Filter

getFilterConfig

public javax.servlet.FilterConfig getFilterConfig()

setFilterConfig

public void setFilterConfig(javax.servlet.FilterConfig filterConfig)


Copyright © 2002-2012 itracker. All Rights Reserved.