10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Filtering Requests and Responses<br />

BookDetailsServlet generates a page that looks like Figure 4–2.<br />

Filtering Requests and Responses<br />

114<br />

FIGURE 4–2 Book Details<br />

A filter is an object that can transform the header and content (or both) of a request or response.<br />

Filters differ from web components in that filters usually do not themselves create a response.<br />

Instead, a filter provides functionality that can be “attached” to any kind of web resource.<br />

Consequently, a filter should not have any dependencies on a web resource for which it is acting<br />

as a filter; this way it can be composed with more than one type of web resource.<br />

<strong>The</strong> main tasks that a filter can perform are as follows:<br />

■ Query the request and act accordingly.<br />

■ Block the request-and-response pair from passing any further.<br />

<strong>The</strong> <strong>Java</strong> <strong>EE</strong> 5<strong>Tutorial</strong> • June 2010

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!