Hi Ansari Thanks for reply.. Iam assigning HttpSessionBindingEvent.getSession() to HttpSession variable in a Listener class.. what I need is getLastAccessedTime();and getMaxInactiveInterval()...iam able extract maxInactive interval time...but when I invoke getLastAccessedTime()..it is throwing IllegalStateException.... I thought if there is any alternate way... Thank you
Well, we encounter IllegalStateException upon invoking getLastAccessedTime() on an invalidated session. Whereas the other method will give you the result anyway.
hi Ansari, I knew that it is being invalidated session.. it goes like this..... HttpSession session = bindingEvent.getSession(); long l_access = session.getLastAccessedTime(); ...... Thanks
William Brogden
,
Author and all-around good cowpoke
Thats what the API says - binding listener gets called when the container is invalidating the session. So why not make your session variable hold its own copy of the access time, updated every time the session is accessed. Bill
Thats what the API says - binding listener gets called when the container is invalidating the session. So why not make your session variable hold its own copy of the access time, updated every time the session is accessed.
Thank you william, Please can you elaborate the above.
Iam assigning HttpSessionBindingEvent.getSession() to HttpSession variable in a Listener class..
As I understand it, you have created a class implementing HttpSessionBindingListener and attach an instance of this class to each new session. In the valueUnbound method you are trying to get at the session with the Event getSession() method so you can use the session method getLastAccessedTime() - this fails because at this point the session is invalid.
What I am saying is to add a timestamp variable to this custom class - update it everytime you process a request. When the valueUnbound method is called you will have the last access time in the object and wont have to call a session method.