wood burning stoves*
The moose likes Servlets and the fly likes Questions re: response.getOutputStream() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Questions re: response.getOutputStream()" Watch "Questions re: response.getOutputStream()" New topic
Author

Questions re: response.getOutputStream()

Richard Olson
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Hi,

Hi,

I'm a newbie try to complete the following goal. We need a utility for capturing or intercepting HTTP responses then writing the output to a file for troubleshooting purposes; something like a sniffer, but without packet info.

I've tried various methods, but so far no success. I�ve tried using ServerOutputStream sOutStr = response.getOutputStream(). How do I write the output to a file? No write methods exist for writing ServerOutputStream to a file. I looked at some of the other streams, but none seem to fit my purposes or I missed the boat.

Any ideas because I�m confused. Hopefully, my description makes sense.

Thanks,
Rich
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The typical approach (which isn't real friendly to newbies) is to wrap the response in an instance of HttpServletResonseWrapper and override the methods needed to alter the response's behaviour.

I have a rough example of this on my site:
http://simple.souther.us/capture.war

In it the response is captured in a filter and written to stdout.
I could be altered very easily to write the output to file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Richard Olson
Greenhorn

Joined: Mar 15, 2004
Posts: 15
Thanks, Ben, I'll take a look
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions re: response.getOutputStream()