• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to store files in session?  RSS feed

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

in my webapp I need to provide data in serveral formats for download: excel, xml and pdf. The question is: after I have generated these documents where do I store them? Should I save them on the local filesystem or is there a way to store the documents in the session?

cheers,

Pete
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If u have large chunks of information, I would recommend retrieving them fresh each time they need to print the report.

Saving large amount of data in your session doesnt seem wise unless you need it repetedly all over the application.
 
Pete Neu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree it's not good to keep the files longer than needed. But the point is how can I provide them just in time? First I do need to generate them and afterwards I need to provide a URL where the files are located on the filesystem. Is there any other way around this?
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Storing files in local file system isn't so bad idea, however you should consider the following:
1. cleanup files after usage or server crash.
2. keep files until persistent session keeps reference to them
3. share files in clustering configuration, when session can migrate from one to another box
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First I do need to generate them and afterwards I need to provide a URL where the files are located on the filesystem. Is there any other way around this?


You could write the "file" to a ByteArrayOutputStream and save a reference to the final byte[] in the session. The servlet responding to the request for that URL would grab the byte[] and write it to the output stream.
Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!