CHAPTER 11 ADVANCED FILTERING TECHNIQUES 439 Figure (Web server application)

CHAPTER 11 ADVANCED FILTERING TECHNIQUES 439 Figure 11-4. This sequence diagram shows how the various VisAudit classes cooperate to filter the response from a web component. Note that you must wrap the response with your own custom version during the request s inbound trip, before you call Chain.doFilter(). In fact, the following happens: 1. The filter supplies a custom wrapped version of the response to downstream filters when it calls the Chain.doFilter() method. 2. This custom wrapped response object hands down a custom OutputStreamor PrintWriter object that is actually a byte array managed in your own code. 3. When downstream filters, or the resource processor, write to your custom OutputStream or PrintWriter, you re buffering all the output. 4. When downstream filters, or the resource processor, flush or close your custom OutputStream or PrintWriter, you examine the buffered output for the closing tag and insert your auditing information just before it (if found). Any downstream filters on the inbound trip (including the actual resource processor) are writing their data into your custom stream. Of course, it s possible that some other downstream filters may perform further wrapping of your custom response with one of their own. The filter-chaining mechanism supports this successive nested wrapping of the response (and the request) as a means of multiple layers of content interception. In this case, your custom response wrapper object will add the Big Brother is watching you visual audit message to all resources that are accessed through this filter. End users will see this auditing message at the bottom of every resource that they access and won t be able to tell that the output originates from a filter. Now let s examine the source code for this filter.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.

Leave a Reply