I want to know how HttpSessionBindingListener will be notified and also why the HttpSessionListener wii not be notified?
HttpSessionBindingListener will be notified if the object which is set in the session implements HttpSessionBindingListener. The valueBound() method will be called when an object implementing this listener got added to the session.
HttpSessionListener is for HttpSession Life cycle events. sessionCreated() and sessionDestroyed() are the methods in it.
HttpSessionBindingListener and HttpSessionAttributeListener are the 2 listeners that get notified when you add some object to session.
If the JavaBeans in the session are not serializable, the JVM will not know how to marshal the data across a network, and unmarshal the data on the other side. As a result, your applications will fail.
In a distributed environment, the data you put into your session must be serializable, otherwise you will face serious problems when you move to a clustered environment.
<opinion> Making a bean serializable is not a dificult thing to do. Any programmer too lazy to conform to this interface when developing code deserves whatever runtime errors they run into at deployment time. </opinion>