You probably have some User object that you store in the session. What you can do is you can implement the HttpSessionBindingListener interface on this object. The valueUnbound() method of that interface will be called when the session is dropped.
http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionBindingListener.html
Note that a session does not end directly when the browser is closed, the session has to time out first on the server side.
Thanks for the reply.
I'm not too sure this is what I'm after. I'm quite new to JSP so forgive me.
Basically, I have a website which is an online shop. The basket uses a bean. I just want to empty the basket and update the database when the session ends.
Any ideas?
Thanks once again!