The approach will depend on what you mean by active user.
If you roll your own login, this is pretty easy to do.
I have a demo application on my site that does exactly what you're trying to do.
http://simple.souther.us/not-so-simple.html Look for SessionMonitor.
Again, if you're just starting out with programming, Java, Servlets and/or JSP, this project might be a little too advanced.
In a nutshell, I bind a map to context scope that holds references to all the active sessions. When someone logs in I bind a userBean object to their session and then add their sessionId to that map. I use a SessionListener to insure that the sessions are removed from the map when they're invalidated.
Note: This approach will not work in a clustered environment as it is.