CHAPTER 3: Best Practices in Java EE Web Development 147
Note A good enterprise application consists of multiple tiers, and each tier concentrates on its own
responsibilities/concerns, as explained in Chapters 1 and 2.
Table 3-24. Presentation Tier Java EE Patterns
Presentation Tier Pattern Description
Intercepting Filter Preprocessing and postprocessing of a client web request and response
Front Controller Centralized access point for presentation tier request handling to support
the integration of system services, content retrieval, view management,
and navigation
View Helper Encapsulating business logic so that it is not intertwined with the
presentation logic
Composite View Managing the layout of the view independent of the content
Service to Worker Assembling a microframework of front controller and view helper with a
dispatcher component
Dispatcher View Assembling a microframework of front controller and view helper with a
dispatcher component
Client
Response
Response Filters
Intercepting Filter
Request
Response
Servlet Container
Request
Request Filters
Filter 1 Filter n Servlet
Figure 3-9. Intercepting Filter pattern
In the sections that follow we will look at each of these Java EE web tier patterns.
Intercepting Filter
A web application receives different types of requests that require some kind of processing, for
example, to check whether the client has to be authenticated before proceeding with navigation. The
best technique to provide a processing mechanism for requests is to use a processing component
called a filter. Filters are used when you need to provide request preprocessing or postprocessing
functionalities. The Intercepting Filter pattern comes along with the introduction of filters to the
Servlet specification. This pattern uses one or more filters plugged into the current application to
provide services such as authorization, compression, encryption, and logging. Figure 3-9 illustrates
the Intercepting Filter pattern.