• 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

session scope quary

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi friends,

i have a requrement to store FileItem(uploaded file using apache fileupload classes) objects in session scope using setAttrubute method.

would it be reliable to store these objects in session scope, so that further i can retrieve it again without having any problem?

is there any other solution?
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why dont you store the file on server?
you can have file name or path as a session attribute.
 
Nidhi Nagre
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


sudhir wrote:
why dont you store the file on server?



actually i want to use actual file data after another request without having the overhead of retrieving it again from server's directory using servlet.
would it be better or storing and retrieving again from server be better?


you can have file name or path as a session attribute.



doing so, will the actual file data be available in session attribute?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In general, it's a bad idea to store anything that isn't serializable in session scope. Things like database connections, input streams, and file handles are not serializable because they are not really data structures.

Having non-serializible objects in session scope will cause problems with session persistance and with session replication.

It would be better to read the file when you need it and explicitly close the stream as soon as you're done with it.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic