I am developing a project in Java in which I want the count of all active sessions in Tomcat. Based on that I want to see how much of those users are active and actually usi
Two more approaches to add, both of which I've been using all the time.
1. VisualVM
To find out the number of active sessions, you can use Tomcat's internal statistics that can be accessed using JMX (Java Management Extension).
Practically, a profiling tool such as VisualVM or Java VisualVM can be used to access the JMX statistics, such as the number of active sessions, on the MBeans tab (See below the screenshot)
2. JavaMelody
You can also use a JavaEE applications monitoring tool, such as JavaMelody, which helps you monitor Java or Java EE applications in QA and production environments.