Filling and Spilling
One of the requirements from the FRD was that if the user quits his session and has items in the cart that should be remembered the next time the user logs in. In e-commerce parlance, this is called “filling and spilling” the cart.
To accomplish this, you need to be able to detect when the user's session has gone away. The Servlet specification refers to this as “session invalidation” and (luckily) offers an easy way to watch for it.
When you give an object session persistence (with useBean or manually with pageContext.setAttribute), you can take advantage of an interface provided by Tomcat called HttpSessionBindingListener. If an object implements this interface and is bound into a session, it will be notified via this interface ...