Hi I am following the code from this link: Capture and log the response body
However the server return error 503 which is really weird?
This is my code:
final CopyPrintWriter writer = new CopyPrintWriter(servletresponse.getWriter());
chain.doFilter(servletrequest, new MyResponseWrapper(
(HttpServletResponse) servletresponse){
@Override
public PrintWriter getWriter() {
return writer;
}
});
log.debug("Test - " + writer.getCopy());
writer.close();
Inside the filter class I added some logging:
12:03:22,404 INFO MyFilter:43 - Before invoking chain
12:03:24,107 DEBUG MyFilter:59 - Test -
12:03:24,108 INFO MyFilter:73 - After invoking chain
The client side receives HTTP error 503 from this code. And also from the log writer.getCopy() returns an empty string? What could be the reason?
EDIT: Removing the CopyPrintWriter related codes and not overriding getWriter(), the server returns OK with html.