|
Summary
In this article we learned what are sessions and how to count active sessions. We learned that to count active sessions we have to create a simple Java class and implement HttpSessionListener interface which is present in the javax.servlet.http package. This interface contains just two methods relative to session created and destroyed events.
We also learned how to tell the server about our listener class by putting special <listener> and <listener-class> tags in /WEB-INF/web.xml file.
We finally created a JSP page to try out our session listener class and found out that it was working well and we were able to see a count of active users on the site. Summary
In this article we learned what are sessions and how to count active sessions. We learned that to count active sessions we have to create a simple Java class and implement HttpSessionListener interface which is present in the javax.servlet.http package. This interface contains just two methods relative to session created and destroyed events.
We also learned how to tell the server about our listener class by putting special <listener> and <listener-class> tags in /WEB-INF/web.xml file.
We finally created a JSP page to try out our session listener class and found out that it was working well and we were able to see a count of active users on the site.
|