EMUmail is a CGI program that runs well on all popular web servers. It allows users to access their POP3/IMAP email at any time and from anywhere, using only a web browser. EMUmail is completely customizable in the commercial verison.
With this article you can have a detailed explanation about creating JSP pages and session listener class with which can count the active users of your website. The session as described in this article, is sort of temporary unique connection between the server and client, which enables the server to keep track of a specific user. The article also provides an online demo. The session can run of a servlet container or application server that supports Servlet 2.3 specification.