background image

Filtering Requests and Responses

<< Generating HTML Markup | Programming Filters >>
<< Generating HTML Markup | Programming Filters >>

Filtering Requests and Responses

BookDetailsServlet
generates a page that looks like
Figure 4­2
.
Filtering Requests and Responses
A filter is an object that can transform the header and content (or both) of a request or response.
Filters differ from web components in that filters usually do not themselves create a response.
Instead, a filter provides functionality that can be "attached" to any kind of web resource.
Consequently, a filter should not have any dependencies on a web resource for which it is acting
as a filter; this way it can be composed with more than one type of web resource.
The main tasks that a filter can perform are as follows:
Query the request and act accordingly.
Block the request-and-response pair from passing any further.
FIGURE 4­2
Book Details
Filtering Requests and Responses
The Java EE 5 Tutorial · September 2007
114