Chapter 13. Filters and Wrappers: The Power of Filters

image with no caption

Filters let you intercept the request. And if you can intercept the request, you can also control the response. And best of all, the servlet remains clueless. It never knows that someone stepped in between the client request and the Container’s invocation of the servlet’s service() method. What does that mean to you? More vacations. Because the time you would have spent rewriting just one of your servlets can be spent instead writing and configuring a filter that has the ability to affect all of your servlets. Want to add user request tracking to every servlet in your app? No problem. Want to manipulate the output from every servlet in your app? No problem. And you don’t even have to touch the servlet code. Filters may be the most powerful web app development tool you have.

Objectives

Filters

3.3

Describe the Web Container request processing model; write and configure a filter; create a request or response wrapper; and given a design problem, describe how to apply a filter or wrapper.

11.1

Given a scenario description with a list of issues, select a pattern that would solve the issues. The list of patterns you must know are: Intercepting Filter, Model-View-Controller, Front Controller, Service Locator, Business Delegate, and Transfer Object.

11.2

Match design patterns with statements describing potential benefits that accrue from the use of the pattern, for any of the following patterns: Intercepting Filter, Model-View-Controller, Service Locator, Business Delegate, and Transfer Object.

Coverage Notes:

This objective is covered completely in this chapter.

Filters, which are covered in this chapter, are an example of (imagine this) the Intercepting Filter pattern. We don’t cover pattern-specific info until the Patterns chapter, but it’s in THIS chapter where you actually see a design that demonstrates the Intercepting Filter pattern.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset