public class CharacterEncodingFilter
extends java.lang.Object
implements javax.servlet.Filter
ignore
initialization parameter. This parameter
is required, so there is no default.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 the Accept-Language
and User-Agent
headers, or a value stashed in the current
user's session.
Modifier and Type | Field and Description |
---|---|
protected java.lang.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 and Description |
---|
CharacterEncodingFilter() |
Modifier and Type | Method and 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 filterConfig)
Place this filter into service.
|
protected java.lang.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.
|
protected java.lang.String encoding
protected javax.servlet.FilterConfig filterConfig
protected boolean ignore
public void destroy()
destroy
in interface javax.servlet.Filter
public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
doFilter
in interface javax.servlet.Filter
request
- servlet request we are processingresponse
- servlet response we are creatingchain
- filter chain we are processingjava.io.IOException
- if an input/output error occursjavax.servlet.ServletException
- if a servlet error occurspublic void init(javax.servlet.FilterConfig filterConfig)
init
in interface javax.servlet.Filter
filterConfig
- The filter configuration objectprotected java.lang.String selectEncoding(javax.servlet.ServletRequest request)
null
.
The default implementation unconditionally returns the value configured by the encoding initialization parameter for this filter.
request
- The servlet request we are processingCopyright © 2003-present Jodd Team