Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Stardeveloper RSS Feed
Newsletter
Enter your email address below to be informed every time a new article is posted at Stardeveloper.com:

You can follow Faisal Khan on Twitter
Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (10)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)
Log In
UserName Or Email:

Password:

Auto-Login:

Miscellaneous Links
  Submit Article

Hosted by Securewebs.com
 
Home : J2EE : Servlets : Counting Active Users using JSP
 

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.


Previous ( 1 Gone )( No Further Pages )

See all comments and questions (post-ad) posted for this tutorial.


Related Articles
  1. J2EE Web Application Events

Comments/Questions ( Threads: 9, Comments: 16 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. sessionDestroyed ( 1 Reply )
  2. Somethings not working
  3. How to count the number of Users visited by Website and display it? ( 1 Reply )
  4. Re:Counting Users
  5. Listener not accepted in web.xml ( 1 Reply )
  6. Problem with sessionDestroyed method ( 2 Replies )
  7. Getting an attribute from the session from the SessionEvent doesn't work in Tomcat
  8. reg error
  9. This Doesn't Work in Orion ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed to.

 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.