Accessories source code
However, the above code will fail with the RESIN server. Because RESIN does not implement the getWriter method, it is replaced with getOutputStream, so you must modify some code to cater to the RESIN operating environment:
/ ** * START File FileCaptureResponseWrapper.java * / package com.junjing.filter; import javax.servlet *;. Import javax.servlet.http *;. Import java.io *;. Public class FileCaptureResponseWrapper extends HttpServletResponseWrapper {private CharArrayWriter output ; public String toString () {return output.toString ();} public FileCaptureResponseWrapper (HttpServletResponse response) {super (response); output = new CharArrayWriter ();} public PrintWriter getWriter () {return new PrintWriter (output);} public void writeFile (String fileName) throws IOException {FileWriter fw = new FileWriter (fileName); fw.write (output.toString ()); fw.close ();} public ServletOutputStream getOutputStream () throws java.io.IOException {return new ServletOutputStream (); public void write (int b) throws oException {Output.write (b);} public void write (byte b []) throws ioException {Output.write (New String (B, "GBK")); } Public void write (byte b [], int off, int LEN)............. Write (new string (b, off, len));}};} public void write {output (output.tochararray ());}} / ** * end file file FileCaptureresponseWrapper.java * /