All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sas.servlet.filters
Class CharacterEncodingFilter

    com.sas.servlet.filters.CharacterEncodingFilter

All Implemented Interfaces:
  javax.servlet.Filter

    public class CharacterEncodingFilter

implements javax.servlet.Filter

Servlet filter which sets the character encoding on every request. If default returned value of request.getCharacterEncoding() is null, then the servlet container's default encoding will usually be used. This may cause problems when getting encoded parameters off the request. It is recommended to use this filter to set the request's encoding to a desired value, such as UTF-8.

To set the request's encoding, set the encoding value in the web.xml filter declaration initial parameters. The following filter declaration and mapping shows the typical web application web.xml entries:

     <filter>
      <filter-name>CharacterEncodingFilter</filter-name>
      <filter-class>com.sas.servlet.filters.CharacterEncodingFilter</filter-class>
      <init-param>
       <param-name>encoding</param-name>
       <param-value>UTF-8</param-value>
      </init-param>
     </filter>

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

Field Summary
`static java.lang.String` | `encoding`

Constructor Summary
`CharacterEncodingFilter()`

Method Summary
`void` | `destroy()` Called by the web container to indicate to a filter that it is being taken out of service
`void` | `doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)` Set the character encoding to be used to interpret request parameters for this request.
`void` | `init(javax.servlet.FilterConfig filterConfig)` Called by the web container to indicate to a filter that it is being placed into service.

Field Detail

### encoding

    public static final java.lang.String encoding

See Also:
  Constant Field Values

Constructor Detail

### CharacterEncodingFilter

    public CharacterEncodingFilter()

Method Detail

### doFilter

    public void doFilter(javax.servlet.ServletRequest request,
                         javax.servlet.ServletResponse response,
                         javax.servlet.FilterChain chain)
                  throws java.io.IOException,
                         javax.servlet.ServletException

  Set the character encoding to be used to interpret request parameters for this request.

  Specified by:
    `doFilter` in interface `javax.servlet.Filter`
  Parameters:
    `request` - The servlet request we are processing
    `result` - The servlet response we are creating
    `chain` - The filter chain we are processing
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

### init

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

  Called by the web container to indicate to a filter that it is being placed into service. The encoding is set by specifying a value in the init-param section of the web.xml filter declaration.

  Specified by:
    `init` in interface `javax.servlet.Filter`
  Parameters:
    `filterConfig` - The filter configuration object
  Throws:
    `javax.servlet.ServletException`

### destroy

    public void destroy()

  Called by the web container to indicate to a filter that it is being taken out of service

  Specified by:
    `destroy` in interface `javax.servlet.Filter`

All Libraries | This Library | Package | Class | Use | Tree | Deprecated | Index | Grand Index | Help
|  | Components |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 SAS Institute Inc. All Rights Reserved.