I'm trying to filter my http response coming out of the app server - I've tested with both ATG and jboss. The problem is that when using the filter with a response wrapper the response disappears. In ATG I get a blank page, and jboss a 404.
The filter is very simple at this stage, simply getting the response and wrapping it for modification, and chaining the filter. Eventually I want to modify the html.
I can see the html output in the console, so I know the filter executes, but the page never makes it to the browser. If I change the chain.doFilter(request, buffer) to chain.doFilter(request, response) it works fine - but then I won't be able to modify the response...
I'd appreciate any thoughts, I'm running out of ideas! Thanks.
PrintWriter out = response.getWriter(); ResponseBuffer buffer = new ResponseBuffer((HttpServletResponse) response); chain.doFilter(request, buffer);
// get page content String contents = buffer.toString(); log.info(contents);
// TODO stuff here
// send the page to the browser CharArrayWriter caw = new CharArrayWriter(); caw.write(contents); response.setContentLength(caw.toString().length()); out.write(caw.toString()); out.close();
I haven't touched ATG Dynamo in years. What version of the servlet spec does it comply with? Filters were introduced in 2.3.
Joined: Nov 16, 2004
It's ATG 6.1, uses the 2.3 spec but the old 1.3.1 JDK. That should not cause any trouble. The atg application is Struts, and the filter is set catch any .do requests and post-process the response. Your code displays the html in the console, but the result never makes it to the browser.
It seems like a chaining problem, but the application chains correctly if the original response is used in the chain.doFilter, not the wrapper. Strange...