Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

update a HashMap using a servlet and ServletContextListener with timer  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two java classes, the first is a Servlet that register users access to the same servlet, the second class implements a ServletContextListener and update the HashMap removing the expired access.I need this Application to obtain a list of online users on an android app, so if you know an easiest way please tell me.

this is the code:



Servlet:


at the moment the application doesn't work fine, because the update doens't happen and after few minutes a ConcurrentModificationException occurs...
 
Alex Rome
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed the issue about ConcurrentModificationException changing HashMap with ConcurrentHashMap but now when the ServletContextListener remove some keys from the map, when I print this map from the servlet, it prints all the keys, also the removed keys. Why?

EDIT: I fixed also the latest issue
 
I child proofed my house but they still get in. Distract them with this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!