The 2 methods in this interface are valueBound and value unbound. An argument is passed to each: HttpSessionBindingEvent.
My question pertains to the 2 methods on this HttpSessionBindingEvent class that are provided ;
String getName() returns the name of the attribute that was used in the bind or unbind, and
HttpSession getSession() returns the HttpSession object from which the object is bound or unbound.
Why these 2 methods? If the event is sent to the object that is getting bound or unbound, then why would anyone need the name within that object? And what would anyone use the getSession method for?
I am storing objects in the servlet context to lock resources on a web-container-wide basis, and it would be nice if a session-timeout would release the locks for me in the servlet-context-held object. But since I don't get what these two HttpSessionBindingEventClass methods are good for, I am wondering if I am missing something important in my understanding?
United Health Group
Hartford, CT, USA
You have to have getSession in order to get at other information attached to the session. For example, suppose you wanted to be able to detect an incomplete purchase order so you could save it and present it again the next time the user logged on.
It sounds like the example in your second paragraph is implying a valueUnbound event from the session getting invalidated, per the phrase 'the next time the user logged on'. If the session is getting invalidated, then there wouldn't be any other session-attached information to get at, right?
Could you clarify a bit more?
Originally posted by Stephen Peterson:
[..]It sounds like the example in your second paragraph is implying a valueUnbound event from the session getting invalidated, per the phrase 'the next time the user logged on'. If the session is getting invalidated, then there wouldn't be any other session-attached information to get at, right?
When you valueUnbound() a session, by say, invalidating the session, you may want to save some important information of that session before this.The method, getSession() will allows you to do so.The next time the user logs in, you may provide him with that information.For example, say you could store the full name of a person associated with a userName, so you don't need to go the DB to get this information.
I am also confused about the getName() method.It makes sense, when you are playing with more than one session instances on the JSP page.But why would you want this to happen?William Brogden, could you explain?