CHAPTER 11 ADVANCED FILTERING TECHNIQUES 437 Figure 11-1. A request from a client constitutes the downstream (inbound) trip of a request/response cycle. The response from a web application constitutes the upstream (outbound) trip. Filter 1: A Visual Auditing Filter The first filter that you ll tackle is similar to the AuditFilter that you developed toward the end of Chapter 10. Like the AuditFilter, it will be deployed by using the following web.xml fragment: VisAudit Filter com.apress.projsp.VisAuditFilter VisAudit Filter /* Unlike the previous AuditFilter, instead of quietly writing the audit information to the log, this filter will include the auditing information in the output of the resource. Figure 11-5 in the section Configuring and Testing the Filter shows an example of this filter being applied to a JSP web page. Note the audit information at the bottom of the page this information is inserted by the filter, and it changes with every access to the page. Wrapping the Response Object for Content Modification The crucial concept to understand from this example is custom response wrapping. This is also one of the most difficult techniques to grasp for novice filter programmers. In custom response wrapping, you provide your own implementation of a custom response object to downstream filters and resources, with the response object that was passed to you wrapped inside. This means that you can modify the response content (inside your custom response
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.
This entry was posted
on Tuesday, February 19th, 2008 at 6:06 pm and is filed under Jsp.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.