Is it possible to find out the number of open sessions reliably in Tomcat (i.e. not only the amount of users who have logged in since [current time]-[session time out], but the number of sessions stored on the server)?
views:
325answers:
3
+4
A:
You can find this info using JMX. See here for how to enable JMX and what variables to query.
Using an Ant JMX task you can use:
<!-- get all sessions and split result as delimiter <em>SPACE</em> for easy
access all session ids directly with ant property sessions.[0..n].
-->
<jmx:invoke
name="Catalina:type=Manager,path=/ClusterTest,host=localhost"
operation="listSessionIds"
resultproperty="sessions"
echo="false"
delimiter=" "
/>
but you can use other tools e.g. JConsole.
Brian Agnew
2009-09-29 12:27:40
A:
You can find this with the builtin Manager as well at http://server:8080/manager/status
If you don't have an admin login enabled, edit conf/tomcat-users.xml
and add a user with role="admin"
. More info in the Tomcat documentation here.
matt b
2009-09-29 12:43:32
+2
A:
If you need this info in your application, you can trace when sessions are created or destroyed by implementing HttpSessionListener and adding it to your server context.
http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSessionListener.html
laura
2009-09-29 12:50:18