This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes serializable object in httpsession Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "serializable object in httpsession" Watch "serializable object in httpsession" New topic

serializable object in httpsession

Martin Lira
Ranch Hand

Joined: May 26, 2004
Posts: 97
I have a webapp that stores an object (Ex. class Person:String first, last, dob, Address address, etc) in the httpsession. Is it required to make the object implement the serializable interface. I do not have a distributed system.

Are there any pros or cons if i make such objects serializable?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

The only harm in a non-distributed system is that your sessions won't persist over app restarts.

The app server will try to serialize the session object and all nested objects when the server shuts down. If any nested objects do not impliment serializable, the write fails.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: serializable object in httpsession