• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Is there any person worked on HashMap and Session

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic