javaservletsweb-applicationsservlet-3.0

Why does a session variable have to be serializable?


When trying to store a List variable of custom objects
session.setAttribute is complaining that’s the variable is not serializable.


Solution

  • Your entire servlet session can be serialized to disk or another store at any moment. So all objects in it must be serializable.