This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes HTTPSession and Serializable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HTTPSession and Serializable" Watch "HTTPSession and Serializable" New topic

HTTPSession and Serializable

Karthik Prabu
Ranch Hand

Joined: Dec 27, 2002
Posts: 48
Is it a good practise to make all the Objects stored in the HTTPSession as Serializable ?

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Doing so allows you to restart the server and keep all of your session data. It will also be necessar if you want to run your app in a clustered environment with session replication.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Do you know how servlet container (any you know) behaves when some session entries can't be stored. Does it abort entire process or just skip "bad" entries?

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
Ragu Ram

Joined: Mar 08, 2004
Posts: 14
I am not sure about all App servers. But Weblogic (atleast 8.1 and above) skips the bad entries as you had mentioned. It also gives a log on the console saying something like 'non serializable content present in session'.
D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

Thanks, it's nice to hear.
I agree. Here's the link:
subject: HTTPSession and Serializable
It's not a secret anymore!