I manage a J2EE application which is deployed on JBoss 3.2.1. As part of my service to my client I want to provide reports which show the number of active sessions. I have
Two possibilities spring to mind: Your JSP can be configured to not create a new session. Stick this at the top of your JSP:
<%@ page session="false"%>
Alternatively, write a JMX MBean which implements JBoss's ServiceMBean interface, and deploy it as a JBos service. This MBean would query the session count, and would appear on JBoss's JMX console. You can use your web browser to monitor it from there, without interfering with your session count.
The JBoss JMX Console already has a integrated session counter in host=localhost,path=/YOUR_PROJECT,type=Manager
By the way, you should use AtomicInteger or synchronize to take care of concurrency problems.