• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Sessions: putValue()

 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick question.
Must the object in

be a Serializable object? Jason Hunter says in Java Servlet Programming that
You can save any set of arbitrary Java objects in a session object.

If this statement is true, then why doesn't putValue()'s object have to be Serializable?
Thanks,
Art
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Art,
From Servet 2.2 spec

The main reasons for session objects must implement Serializable is, a good servlet container may choose to store the session objects to disk often to reduce the memory usage as well as to reduce the risk of losing the session objects in case of an emergency due to power failure/server failure etc.
regds
maha anna

[This message has been edited by maha anna (edited March 08, 2001).]
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Maha Anna, that answers it beautifully.
By the way, and since I've got you, I wanted to thank you for your one-stop shopping (can I say that without paying Amazon?) with regards to the Sun Java Certification mock exams! Your efforts were a big help to me.
And thanks again for clarifying putValue().
Art
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Art! :-) The internet makes it possible. Isn't? One time effort helps many hundreds of people each day.
regds
maha anna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic