xml file by using the
filter element along with the filter-name (arbitrary name), filter-class
(fully qualified class name), and, optionally, init-params subelements.
For instance, given the ReportFilter class just shown, you could make the following
filter declaration in web.xml. It associates the name Reporter with the
actual class ReportFilter (which is in the coreservlets package).
Reporter
coreservlets.ReportFilter
Once you have named a filter, you associate it with one or more servlets or JSP
pages by means of the filter-mapping element. You have two choices in this
regard.
First, you can use filter-name and servlet-name subelements to associate
the filter with a specific servlet name (which must be declared with a servlet element
in the same web.xml file). For example, the following snippet instructs the system
to run the filter named Reporter whenever the servlet or JSP page named
SomeServletName is accessed by means of a custom URL.
Reporter
SomeServletName
Second, you can use the filter-name and url-pattern subelements to associate
the filter with groups of servlets, JSP pages, or static content. For example, the
following snippet instructs the system to run the filter named Reporter when any
URL in the Web application is accessed.
Pages:
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109