Adding a Filter to a Web Application

A filter is a Java class that is called to process client requests or the server's response. Filters can be used to modify the request header or the content of a servlet request or response.

Filters can be mapped to a URL or a servlet name. When a filter is mapped to a URL (path-mapped), the filter applies to every servlet and JavaServer Page (JSP) in the Web application. When a filter is mapped to a servlet name (servlet-mapped), it applies to a single servlet or JSP. Path-mapped filters are executed first, followed by servlet-mapped filters.

  1. In the WorkSpace Navigator of the Web Application Development perspective, select web.xml.
  2. Select the Filter tab.
  3. Click Add. A new filter is added with the default name "NewFilter x."
  4. (Optional) Change the default filter name to a unique, logical name in the Name field of the General Information section.
  5. Click Browse adjacent to the Filter Class field and select a class.
  6. (Optional) Type a name in the Display name field.
  7. (Optional) Enter a description.
  8. Click Add in the Filter Mappings section.
  9. Type the URL that you want to map to and click OK.
  10. Click Add in the Initialization Parameters section.
  11. Enter a name and value and click OK.
  12. (Optional) Click Browse in the Icons section. You can browse for and select either a small or large icon.
Related concepts
Configuring the web.xml File
Related tasks
Adding a Servlet to a Web Application
Adding a Resource Reference to a Web Application
Adding an EJB Reference to a Web Application
Adding a Context Parameter to a Web Application
Adding a Listener to a Web Application
Adding a Tag Library to a Web Application
Adding a Welcome File to a Web Application
Adding an Error Page to a Web Application
Adding MIME Mapping to a Web Application
Adding an EJB Local Reference to a Web Application
Adding a Resource Environment Reference to a Web Application
Adding an Environment Entry to a Web Application
Adding Security to a Web Application
Defining the Login Configuration of a Web Application

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.