How to redirect a Java ResponseWriter?
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 outpu开发者_如何学JAVAt there.
Is there an easy solution to redirect the ResponseWriter to standard output?
How about this?
ResponseWriter rw1, rw2; // ...
rw2 = rw1.cloneWithWriter(new PrintWriter(System.out));
Documentation for ResponseWriter
- http://developers.sun.com/docs/jscreator/apis/jsf/javax/faces/context/ResponseWriter.html#cloneWithWriter(java.io.Writer)
Use whichever writer your find most convenient
- http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/io/PrintWriter.html
And finally, system.out.
- http://download.oracle.com/docs/cd/E17476_01/javase/1.4.2/docs/api/java/lang/System.html#out
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.
精彩评论