• Post Reply Bookmark Topic Watch Topic
  • New Topic

session scope quary

 
Nidhi Nagre
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?
 
sudhir nim
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?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!