• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to store files in session?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic