concept portlet filter in category java

appears as: portlet filters, A portlet filter, portlet filter, The portlet filter, portlet filters
Portlets in Action

This is an excerpt from Manning's book Portlets in Action.

The two versions of the Java Portlet Specification that currently exist are 1.0 (described by JSR 168) and 2.0 (described by JSR 286). The 2.0 specification addresses most of the frequently required features of portlets that were missing from the 1.0 specification, such as resource serving (discussed in chapter 12), inter-portlet communication (chapter 11), and portlet filters (chapter 13). Most portlet containers support both specifications, and the 2.0 specification is backward compatible with the 1.0 specification.

A portlet filter is a reusable component that allows you to write request- and response-processing logic that can be applied to multiple portlets and that can be reused in different portlet applications with just a few configuration steps. A portlet filter is similar to a servlet filter, and it’s responsible for preprocessing requests before they’re handled by the portlet and for postprocessing responses before they’re sent to the portal server.

In this chapter, we’ll look at different types of portlet filters, their lifecycles, implementation, configuration, and how they can be used individually or in combination with other portlet filter types. We’ll also see how portlet filters can be used by the Book Catalog portlet to dynamically set the portlet title and to convert the title of a book into a hyperlink pointing to a Wikipedia page related to the subject covered in the book. By the end of this chapter, you’ll understand how portlet filters are typically used to preprocess requests and post-process responses, and how they can be used together to create a filter chain.

Figure 13.2. The portlet filter lifecycle. The portlet filter does the preprocessing of the request or the postprocessing of the response. FilterChain passes the request to the next filter in the chain, or to the target portlet if the filter is the last filter in the chain.