web.xml Visual Editor: Servlet Filters

See Also 

Use the Servlet Filters section and the Filter Mappings section of the web.xml Visual Editor to add, remove, and view the deployment information of your web application's servlet filters. A filter is a piece of re-usable code that modifies requests to and responses from a servlet.

Filters can perform many functions, including (but not limited to):

To deploy a filter, you must register it in the web.xml file. When you do this, you provide information needed by the server to deploy the filter. For example, you tell the server which types of requests should cause the filter to be deployed.

Before you can register a filter in the web.xml file, you must create it in the New File wizard or import it from your existing sources. You can use the Configure Filter Deployment panel of the New File wizard to register a filter. If you have not done so, or if you want to modify a registered filter's deployment information, use the Filters view of the web.xml Visual Editor.

You open the web.xml Visual Editor from the Projects window by expanding the Web Pages node, then the WEB-INF node, and then double-clicking the web.xml file. Click Filters at the top of the editor to open the Filters view.

First, click Add Filter Element to define the filter element with the following properties:

Next, click Add within the filter element and define its initialization parameters:

Finally, click Add in the Filter Mappings section to map the filter to servlets or URL patterns to which the filter applies:

Note that when you click Remove at the top of the Servlet Filters section, you remove the filter's deployment information from the web.xml file, but you do not remove the filter itself. To delete the filter, right-click it in the Projects window and choose Delete.

See Also
About Servlet Filters
About Deployment Descriptors
About Configuring Web Applications
Configuring Web Application Deployment Descriptors

Legal Notices