Is serialization necessary while writing and reading an object in the same JVM?
Session objects must implement serializable in order to maintain it after restart of server.
As same JVM is used why session objects must implement serializable?
Is serialization necessary while writing and reading an object in the same JVM?
Session objects must implement serializable in order to maintain it after restart of server.
As same JVM is used why session objects must implement serializable?
Serialization is required because the session objects may be stored in a file, a database or may be transported to another service node via network. Even the included objects must implement Serializable
.
Why these requirements were set? Because a session must last longer than a request. Nobody can guarantee that the same JVM will still exist when the next request comes with the same Session ID - so there should be a redundancy or failover solution that ensures that the session will survive. There are many solutions for this, but the actual solution doesn't even matter - but Serialization ensures that it will work.