• Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving Response content to a file.  RSS feed

 
Sudarsan Raman
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know if the content of Response (HTTPSevletResponse) can be saved to a file (in the hard-disk).
(I want to do it in the servlet, i.e. without any user intervention.)
If it is possible then how ?
Thanks & Regards,
Sudarsan.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the content of the response can be saved to a file, but I'm not sure I can see why this might be useful. Presumably you are making the response in your code, so why not just build it to a StringBuffer and write that to disk before you add it to the response and send it back to the browser.
Can you explain a little more about what you want to do this for - there may be other, more obvious, ways of achieveing what you need.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't really possible in Servlets, except as Frank said by caching the data locally first then writing to both the file system and the client at the same time. It's a lot of work though.
You can do it using tags in JSPs and I beieve there is already a caching tag created, although personally I haven't even looked at it. Tags have an extra feature foreign to Servlets, where it is sometimes necessary to cache the entire page, and you can use this feature to retain a local copy of responses to clients.
At least I hear you can, it isn't something I'm interested in trying...
Dave
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like that should be possible with a Filter - on the response side you could substitute your own version of an OutputStream or Writer that wrote to a file as well as to the response.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!