I spent nearly 3 weeks on a response wrapping problem, I didn't yet figured out the cause, I'm working with JDK 1.4 + servlet 2.3 + struts rc2 MVC framework + tiles on JRUN web server. the problem arise when I tried to filter struts actions (*.do) with a wrapping filter, i.e. in WEB.XML I wrote :
OutputStream out = response.getOutputStream(); out.write("<HR>PRE HTML FOR TEST <HR>".getBytes()); GenericResponseWrapper wrapper = new GenericResponseWrapper ((HttpServletResponse) response); chain.doFilter(request, wrapper); out.write(wrapper.getData()); out.write("<HR>POST HTML FOR TEST<HR>".getBytes()); out.close();
so , when calling any action servlet in browser ,the page shows NOTHING and the logged error is :
jrun.servlet.io.ClosedIOException: Response has been closed at jrun.servlet.io.ClosedOutputStream.write(ClosedOutputStream.java:23) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109) at jrun.servlet.http.WebOutputStream.write(WebOutputStream.java:64) at java.io.OutputStream.write(OutputStream.java:58) at filters.WrapperFilter.doFilter(WrapperFilter.java:176) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) .....
Also I noticed that the filter is working fine if my action is forwarding to a JSP page instead of a tiles definition name so instead of mapping the filter to *.do I mapped it to *.jsp :