background image

Specifying Filter Mappings

<< HttpServletResponseWrappe Class | Applying the Filter to Requests >>
<< HttpServletResponseWrappe Class | Applying the Filter to Requests >>

Specifying Filter Mappings

Specifying Filter Mappings
A web container uses filter mappings to decide how to apply filters to web resources. A filter
mapping matches a filter to a web component by name, or to web resources by URL pattern.
The filters are invoked in the order in which filter mappings appear in the filter mapping list of a
WAR. You specify a filter mapping list for a WAR in its deployment descriptor, either with
NetBeans IDE or by coding the list by hand with XML.
To declare the filter and map it to a web resource using NetBeans IDE, do the following:
1. Expand the application's project node in the Project pane.
2. Expand the Web Pages and WEB-INF nodes under the project node.
3. Double-click web.xml.
4. Click Filters at the top of the editor pane.
5. Expand the Servlet Filters node in the editor pane.
FIGURE 4­3
Duke's Bookstore with Hit Counter
Filtering Requests and Responses
Chapter 4 · Java Servlet Technology
119