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 ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.