CHAPTER 11 ADVANCED (Web hosting provider) FILTERING TECHNIQUES 445 When

CHAPTER 11 ADVANCED FILTERING TECHNIQUES 445 When close() is called for the first time, the class transforms the output in the in- memory stream. After the transformation, the class stores the results so the filter can retrieve them later. Multiple calls to close() don t cause a problem in this case. The processStream() method calls the replaceContent() method to transform the in-memory stream and write the transformed output to the wrapped output stream. The replaceContent() method is abstract. Subclasses of this class will provide an implementation for the method. The intention is for subclasses to transform the input byte array and return the transformed array. As you saw in Listing 11-4, VisAuditOutStream.java, that subclass transforms the inBytes byte array by adding additional data to the stream. This is the end of the code analysis for the ReplaceContentOutputStream abstract class. You ll rely on this class for two subsequent filters that transform their outgoing response s content. Configuring and Testing the Filter To deploy the filter, add the filter definition and filter mapping in Listing 11-8 to the web.xml file. Listing 11-8. and< filter-mapping> Elements for web.xml VisAudit Filter com.apress.projsp.VisAuditFilter VisAudit Filter /* This mapping will apply the filter to every resource served by the application. Start by loading the JSP page FindProd.jsp, as shown in Figure 11-5, using the appropriate test URL for the application you created. Figure 11-5. The VisAuditFilter can be used to filter JSP pages. It appends an audit message to the end of the response.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Leave a Reply