Multiple domain web hosting - 428 CHAPTER 10 INTRODUCTION TO FILTERING You

428 CHAPTER 10 INTRODUCTION TO FILTERING You can glean some interesting data from this. The initial compiling and loading of the JSP page took 1578 milliseconds to complete, whereas subsequent access required negligible time. Also, you can see that the requests for FindProd.jsp were processed by only the audit filter. In contrast, the last request for http://localhost:8080/filters1/was processed by all three filters. Notice that because the audit filter did not log anything during the request portion of the processing, its only entry to the log appears after the return from SimpleFilter2 and SimpleFilter1. Writing this potentially useful auditing filter has been quite painless. You ll find in general that, after you re familiar with the model of operation of the Servlet 2.5 filter, writing highly functional filters can be quite straightforward. Other Filter-Like Technologies Prior to Servlet 2.4 filters, there had been many server extension mechanisms based on similar concepts to filtering. In fact, interceptors form a key server-extension mechanism that is used quite heavily in many Tomcat 3.x-based containers. Tomcat 4.x uses a technology called valves to perform filter-like processing. However, there are fundamental differences between filters and these mechanisms: they aren t the same. This section briefly describes the essential differences between the technologies. Filters Aren t Tomcat 3.x Interceptors Interceptors are a server-level extension mechanism for servers that support them. Interceptors are not an application-level technology. Being a server-extension technology, it s specific to Tomcat. Furthermore, effects of interceptors are typically global to the server filter effects are local to the web application that the filters belong to. The general architectures of interceptors and filters are completely different. Interceptors are hooked in modules that are called at specified points in the processing pipeline by the container. There are different types of interceptors for different access points. Filters, however, rely on nested chain calling (and custom wrapping of the request or response) to get their work done. There is only one type of filter. All filters implement the same javax.servlet.Filter interface. Filters Aren t Valves Valves are a system-level mechanism used extensively within the design of Tomcat 4.x and 5.x. On an architectural level, they re almost identical to filters. But that s where the similarity ends. Valves are Tomcat-specific and typically aren t portable to other Servlet 2.5 compatible servers. On the other hand, filters are portable. Valves are also internal to the Tomcat server and have privileged access to many structures and resources that application-level filters cannot access. Filter Design Best Practices There are a few rules of thumb that you should consider when designing and writing filters. Some of these may give you novel ideas on how you can use filters in your own applications,
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Leave a Reply