CHAPTER 11 ADVANCED FILTERING TECHNIQUES 441 a (Web hosting resellers)

CHAPTER 11 ADVANCED FILTERING TECHNIQUES 441 a byte array as input this is the content written into the buffer by the downstream filters and processors. The return value is another byte array, which is the content that will be written to the client. In this case, the code looks for the closing tag to know where to insert the additional content. If the tag is found, the auditing information is added just before the end of the document. The Customized Response Wrapper Class The next class we ll define is the response wrapper called VisAuditResponseWrapper (Listing 11-5). It conveniently inherits from javax.servlet.http.HttpServletResponseWrapper. By using this wrapper class, we can readily wrap any HttpServletResponseobject and override only the methods that we want to customize. The HttpServletResponseWrapper class has provided trivial implementations of all the methods of the HttpServletResponse interface they all call the corresponding method of the class being wrapped. Listing 11-5. VisAuditResponseWrapper.java package com.apress.projsp; import java.io.PrintWriter; import javax.servlet.*; import javax.servlet.http.*; public class VisAuditResponseWrapper extends HttpServletResponseWrapper { private PrintWriter tpWriter; private VisAuditOutStream tpStream; public VisAuditResponseWrapper(ServletResponse inResp, String inAddr, String inHost) throws java.io.IOException { super((HttpServletResponse) inResp); tpStream = new VisAuditOutStream(inAddr, inHost); tpWriter = new PrintWriter(tpStream); } public ServletOutputStream getOutputStream() throws java.io.IOException { return tpStream; } public PrintWriter getWriter() throws java.io.IOException { return tpWriter; } }
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Leave a Reply