How to find out what open sessions my servlet based application is handling at any given moment
问题 I need to write a servlet that, when called, gets information about a list of the currently opened sessions. Is there a way to do this? 回答1: Implement HttpSessionListener, give it a static Set<HttpSession> property, add the session to it during sessionCreated() method, remove the session from it during sessionDestroyed() method, register the listener as <listener> in web.xml . Now you've a class which has all open sessions in the current JBoss instance collected. Here's a basic example: