2

For debug reasons, I want to see the ouput of my ResponseWriter directly in standard output. Because the response will be processed by JavaScript I am not able to see the output there.

Is there an easy solution to redirect the ResponseWriter to standard output?

Thorben Croisé
  • 12,407
  • 8
  • 39
  • 50
  • The accepted answer indicates that you're using JSF. You should really have mentioned that in your question and tags. This facility is namely not (directly) available in Servlet API. – BalusC Jul 16 '10 at 12:15
  • I was not really aware that the ResponseWriter is only available in JSF, I added the tag – Thorben Croisé Jul 16 '10 at 15:04
  • The package name of `ResponseWriter` tells that. Since you tagged `servlets` I initially thought that there's was some layman's ambiguity and that you *actually* meant `response.getWriter()` as you can obtain from `HttpServletResponse`. For that a completely different approach is needed, as suggested by Bozho and answered in detail by me [here](http://stackoverflow.com/questions/3242236/capture-and-log-the-response-body). – BalusC Jul 16 '10 at 15:05
  • The tag "servlets" was not added by me – Thorben Croisé Jul 16 '10 at 15:06
  • Talking about ambiguity in `ResponseWriter` :) In future try to tag as specific as possible. Know what you're actually using. Look at package names and so on. It's not "just" Java and Ajax. Actually, Ajax has not much to do with the *actual* question. – BalusC Jul 16 '10 at 15:08

2 Answers2

2

How about this?

ResponseWriter rw1, rw2; // ...
rw2 = rw1.cloneWithWriter(new PrintWriter(System.out));

Documentation for ResponseWriter

Use whichever writer your find most convenient

And finally, system.out.

mahju
  • 1,156
  • 1
  • 14
  • 21
1

There is - you can wrap your response and writer objects. But in this case there is a better solution: use Firebug. It will tell you what the response has been.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140