• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Saving Response content to a file.

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
My, my, aren't you a big fella. Here, have a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic