Based on your suggestion I tried the code below.
But what seems to be happening is that response.<n> is written as hoped
but the response to the browser fails with
java.lang.IllegalStateException: Cannot forward after response has been
committed
So it's as if the response is used up and unavailable a second time?
class CharResponseWrapper extends
HttpServletResponseWrapper {
private CharArrayWriter output;
public String toString() {
return output.toString();
}
public CharResponseWrapper(HttpServletResponse response){
super(response);
output = new CharArrayWriter();
}
public PrintWriter getWriter(){
return new PrintWriter(output);
}
}
public class MyFilter
implements Filter
{
private FilterConfig filterConfig = null;
private String authorisedGroup = null;
private static int count = 0;
public void doFilter(ServletRequest request, ServletResponse
response, FilterChain chain)
throws IOException, ServletException
{
String sRequest =
((HttpServletRequest)request).getRequestURI();
this.count++;
try{
CharResponseWrapper wrapper = new
CharResponseWrapper((HttpServletResponse)response);
chain.doFilter(request, wrapper);
CharArrayWriter caw = new CharArrayWriter();
caw.write(wrapper.toString());
FileWriter fOut = new FileWriter("d://tmp//response." +
count);
fOut.write(caw.toString());
fOut.close();
chain.doFilter(request, response);
}
catch(IOException e)
{
System.out.println("Exception");
}
}