hi all, i have created a HashMap and in which i am storing my all Sessions. Inside session i am storing an object Of type User class (I have called User class inside .jsp page as a Bean). so codingwise it's like this after creating User user object. session.putValue("user",user); monitor.put(user,session) ; (the session is object Of HttpSession, bydefault we get it in .jsp page and monitor is object Of HashMap class which, i included as a Bean having application scope). Then i set Maximum inactive time to 200 seconds. session.setMaxInactiveInterval(200) ;
now the problem is that after 200 seconds session is expire but the HashMap is still having it's objects/entry in it (naturally). so how can i remove it from HashMap as soon as session's time period is over. i have taken somewhat step for the solution. They are as follows. 1) i have implement HttpSessionBindingListener in Class User and override it's both the methods valueBound() and valueUnBound() 2) when session gets removed valueUnBound() is called successfully but how can i remove the session object from HashMap as we can't access HashMap inside User class. I hope i have clearly write the question and get someone to help me out.
[This message has been edited by Nilesh Soni (edited May 30, 2001).]
I am not entirely familiar with the HttpSessionBindingListener but what I would look into doing is making an extension of the HashMap class (rather than using a HashMap) that listens for the binding events and destroys or cleans itself according to your wishes. Though ... if you only want that data around during the users session, why not just put your HashMap in the session scope? Hope this helps ------------------ Chris Stehno (Sun Certified Programmer for the Java 2 Platform)