The moose likes Servlets and the fly likes Servlet Sessions:  putValue() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Servlet Sessions:  putValue()" Watch "Servlet Sessions:  putValue()" New topic
Author

Servlet Sessions: putValue()

Art Metzer
Ranch Hand

Joined: Oct 31, 2000
Posts: 241
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

Joined: Jan 31, 2000
Posts: 1467
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

Joined: Oct 31, 2000
Posts: 241
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

Joined: Jan 31, 2000
Posts: 1467
Thanks Art! :-) The internet makes it possible. Isn't? One time effort helps many hundreds of people each day.
regds
maha anna
 
 
subject: Servlet Sessions: putValue()
 
Threads others viewed
[newbie] AbstractAction fun...
problem in retreiving value
Why do I need to serialize ALL session objects?
session attributes type
Serialization, can someone elaborate?
IntelliJ Java IDE