For more details on Java regular
expressions, see http://java.sun.com/j2se/1.5.0/docs/api/java/util/
regex/Pattern.html. Finally, BannedAccessFilter provides an
empty body for the destroy method.
2. Filtering behavior in the doFilter method. This method looks
up the requesting and referring hosts by using the getRemoteHost
method of ServletRequest and parsing the Referer HTTP
request header, respectively.
3. A conditional call to the doFilter method of the Filter-
Chain. The filter checks to see if the requesting or referring host is
listed in the HashMap of banned sites. If so, it calls the showWarning
method, which sends a custom response to the client. If not, the filter
calls doFilter on the FilterChain object to let the request proceed
normally.
4. Registration with the daily special servlet; definition of initialization
parameters. First, the filter element associates the name
BannedAccessFilter with the class coreservlets.filters.
BannedAccessFilter. The filter element also includes an
init-param subelement that specifies the prohibited sites (separated
by white space). Because the resource that the competing sites
abuse is the servlet that shows the daily special, the
filter-mapping element uses a servlet-name of Todays-
Special. The servlet element assigns the name TodaysSpecial
to coreservlets.TodaysSpecialServlet. See Listing 5.13.
5. Disablement of the invoker servlet.
Pages:
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280