Web site design and hosting - 430 CHAPTER 10 INTRODUCTION TO FILTERING You

430 CHAPTER 10 INTRODUCTION TO FILTERING You should note that, in general, filters should not maintain state across multiple requests because the very same instance of a filter can service a large number of requests in a given period. Logic requiring this degree of state maintenance is best served by servlets or JSP pages. In other words, the filter should depend on little or no session information to process a request or response. Think of Filters As In-Series Resource Processors When designing web applications that follow the well-documented Model-View-Controller (MVC) design pattern or Model 2 JSP architecture, consider the use of filters as in-series resource processors in conjunction with the request dispatcher. For example, in a push-model web application, a filter may perform part of the controller s responsibility by fetching data from the model and attaching it to the request in the form of attributes for the view component to display. Another interesting example is form processing. When a form is submitted and before the controller component is called, a filter can be used to perform data validation on the incoming form data. Reusing a Filter via Chaining Break up your filter-processing work into reusable, independent, chainable filters whenever possible. This will enhance the reuse potential of the filters and also allow users to use your filters in new and innovative ways. Also design your filters to be easily configurable at deployment time. Often a filter can be reused through the careful planning and use of initialization parameters. Avoid Duplicating System Features Many problems addressed by filters can be solved instead via configuration of standard server features. This is especially true with Tomcat 5, which has logging, authentication, authorization, and fine-grained access control support built-in. Encrypted sessions via Transport Layer Security (TLS), more commonly known as secure sockets (HTTPS), are also supported natively. You should avoid duplicating system features in your filter design. Investigate all the server features first, looking to see whether your filter application can be accomplished by simple server configuration. Write your filter only after you have determined that it s the only appropriate solution, given project requirements and constraints. Avoid Unnecessary Filter Mappings When mapping filters, always use the most restrictive mapping possible use instead of if possible. The overhead of filter operations can be significantly increased if the filter is consistently applied to web resources that don t need it.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Leave a Reply