440 CHAPTER 11 (Web server application) ADVANCED FILTERING TECHNIQUES The
440 CHAPTER 11 ADVANCED FILTERING TECHNIQUES The VisAuditOutStream Class Your custom stream is called VisAuditOutStream (see Listing 11-4), which inherits from a class called ReplaceContentOutputStream (Listing 11-7). ReplaceContentOutputStream is a utility library (abstract) class for creating custom streams to be used in response wrapping. It takes care of buffer management and intercepting the write, close, and flush calls by the downstream filters and processors. You will examine the source code for ReplaceContentOutputStream a little later. The constructor of your VisAuditOutStream takes the output stream to wrap as the first parameter. The second and third parameters contain the IP address and host name of the client accessing the page, and are passed directly from the filter when the custom stream is created. Listing 11-4. VisAuditOutStream.java package com.apress.projsp; class VisAuditOutStream extends ReplaceContentOutputStream { String addr; String host; public VisAuditOutStream(String inAddr, String inHost) { addr = inAddr; host = inHost; } public byte[] replaceContent(byte[] inBytes) { StringBuffer sb = new StringBuffer(inBytes.length); String result = new String(inBytes); String srchString = result.toLowerCase(); int endBody = srchString.indexOf(”