The Apache Tomcat Servlet/JSP Container

The Apache Tomcat 5.5 Servlet/JSP Container

Apache Logo

Links

Top Level Elements

Connectors

Containers

Nested Components

Other

Apache Tomcat Configuration Reference

Container Provided Filters

Table of Contents
Introduction

Tomcat provides a number of Filters which may be configured for use with all web applications using $CATALINA_BASE/conf/web.xml or may be configured for individual web applications by configuring them in the application's WEB-INF/web.xml. Each filter is described below.

This description uses the variable name $CATALINA_BASE to refer the base directory against which most relative paths are resolved. If you have not configured Tomcat for multiple instances by setting a CATALINA_BASE directory, then $CATALINA_BASE will be set to the value of $CATALINA_HOME, the directory into which you have installed Tomcat.

Set Character Encoding Filter
Introduction

User agents don't always include character encoding information in requests. Depending on the how the request is processed, usually the default encoding of ISO-8859-1 is used. This is not always desirable. This filter provides options for setting that encoding or forcing it to a particular value. Essentially this filter calls ServletRequest.setCharacterEncoding() method.

Effectively the value set by this filter is used when parsing parameters in a POST request, if parameter parsing occurs later than this filter. Thus the order of filter mappings is important. Note that the encoding for GET requests is not set here, but on a Connector. See CharacterEncoding page in the FAQ for details.

Filter Class Name

The filter class name for the Set Character Encoding Filter is org.apache.catalina.filters.SetCharacterEncodingFilter.

Initialisation parameters

The Set Character Encoding Filter supports the following initialization parameters:

AttributeDescription
encoding

Name of the character encoding which should be set.

ignore

Determines if any character encoding specified by the user agent is ignored. If this attribute is true, any value provided by the user agent is ignored. If false, the encoding is only set if the user agent did not specify an encoding. The default value is false.

Failed Request Filter
Introduction

This filter triggers parameters parsing in a request and rejects the request if some parameters were skipped during parameter parsing because of parsing errors or request size limitations (such as maxParameterCount attribute in a Connector). This filter can be used to ensure that none parameter values submitted by client are lost.

Note that parameter parsing may consume the body of an HTTP request, so caution is needed if the servlet protected by this filter uses request.getInputStream() or request.getReader() calls. In general the risk of breaking a web application by adding this filter is not so high, because parameter parsing does check content type of the request before consuming the request body.

Note, that for the POST requests to be parsed correctly, a SetCharacterEncodingFilter filter must be configured above this one. See CharacterEncoding page in the FAQ for details.

The request is rejected with HTTP status code 400 (Bad Request).

Filter Class Name

The filter class name for the Failed Request Filter is org.apache.catalina.filters.FailedRequestFilter.

Initialisation parameters

The Failed Request Filter does not support any initialization parameters.


Copyright © 1999-2012, Apache Software Foundation