Class SetCharacterEncodingFilter
- java.lang.Object
-
- org.pentaho.platform.web.http.filters.SetCharacterEncodingFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
- Direct Known Subclasses:
PentahoAwareCharacterEncodingFilter
public class SetCharacterEncodingFilter extends Object implements javax.servlet.Filter
Example filter that sets the character encoding to be used in parsing the incoming request, either unconditionally or only if the client did not specify a character encoding. Configuration of this filter is based on the following initialization parameters:
- encoding - The character encoding to be configured for this request, either conditionally or
unconditionally based on the
ignore
initialization parameter. This parameter is required, so there is no default. - ignore - If set to "true", any character encoding specified by the client is ignored, and the
value returned by the
selectEncoding()
method is set. If set to "false,selectEncoding()
is called only if the client has not already specified an encoding. By default, this parameter is set to "true".
Although this filter can be used unchanged, it is also easy to subclass it and make the
selectEncoding()
method more intelligent about what encoding to choose, based on characteristics of the incoming request (such as the values of theAccept-Language
andUser-Agent
headers, or a value stashed in the current user's session.- Version:
- $Revision: 267129 $ $Date: 2004-03-18 11:40:35 -0500 (Thu, 18 Mar 2004) $
- Author:
- Craig McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description protected String
encoding
The default character encoding to set for requests that pass through this filter.protected javax.servlet.FilterConfig
filterConfig
The filter configuration object we are associated with.protected boolean
ignore
Should a character encoding specified by the client be ignored?
-
Constructor Summary
Constructors Constructor Description SetCharacterEncodingFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Take this filter out of service.void
doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
Select and set (if specified) the character encoding to be used to interpret request parameters for this request.void
init(javax.servlet.FilterConfig localFilterConfig)
Place this filter into service.protected String
selectEncoding(javax.servlet.ServletRequest request)
Select an appropriate character encoding to be used, based on the characteristics of the current request and/or filter initialization parameters.
-
-
-
Field Detail
-
encoding
protected String encoding
The default character encoding to set for requests that pass through this filter.
-
filterConfig
protected javax.servlet.FilterConfig filterConfig
The filter configuration object we are associated with. If this value is null, this filter instance is not currently configured.
-
ignore
protected boolean ignore
Should a character encoding specified by the client be ignored?
-
-
Method Detail
-
destroy
public void destroy()
Take this filter out of service.- Specified by:
destroy
in interfacejavax.servlet.Filter
-
doFilter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
Select and set (if specified) the character encoding to be used to interpret request parameters for this request.- Specified by:
doFilter
in interfacejavax.servlet.Filter
- Parameters:
request
- The servlet request we are processingresult
- The servlet response we are creatingchain
- The filter chain we are processing- Throws:
IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet error occurs
-
init
public void init(javax.servlet.FilterConfig localFilterConfig) throws javax.servlet.ServletException
Place this filter into service.- Specified by:
init
in interfacejavax.servlet.Filter
- Parameters:
localFilterConfig
- The filter configuration object- Throws:
javax.servlet.ServletException
-
selectEncoding
protected String selectEncoding(javax.servlet.ServletRequest request)
Select an appropriate character encoding to be used, based on the characteristics of the current request and/or filter initialization parameters. If no character encoding should be set, returnnull
.The default implementation unconditionally returns the value configured by the encoding initialization parameter for this filter.
- Parameters:
request
- The servlet request we are processing
-
-