• Post Reply Bookmark Topic Watch Topic
  • New Topic

update a HashMap using a servlet and ServletContextListener with timer

 
Alex Rome
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!