• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

session scope quary

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic