// shall I write some keywords here to boost search engine ranking?

Monday, July 31, 2006

Session Persistent in Tomcat

Based on my past experience, I know that Tomcat is able to persist session. Which means user session can be restore after proper shutdown or restart of Tomcat.

However, recently all of my webapps on a Tomcat fail to restore the session. This is strange to me. I do some google to find out where to tweak my Tomcat to enable this. Then I found that it is enable by default, and many people is asking how to disable it.

I try to look into my work directory. When I shutdown, the file "SESSION.ser" which store session is created. When I start Tomcat, it was read then removed. But I still fail to retrieve the items in session.

Then something flash into my mind. The file is "SESSION.ser", ".ser" means serialized object file. The object I put into the session is not serialized, could this be the reason?

After some experiment, what I guess is true. If want to restore the object from session, the object must be serialized.

After doing years of Servlet/JSP, I only realised this by today. What a shame. -_-'''

2 comments:

Anonymous said...

True,

I found out you can also change the serialVersionUID...

It has everything to do with "Read the ** Manual"...

Db said...
This comment has been removed by the author.