How to check the number of client currently logged in ?

Discussion in 'Java' started by james, Apr 7, 2004.

  1. james

    james Guest

    I am developed a web-application which support user authenication with
    JSP/Javabean under Tomcat
    I would like to know how I can let the jsp to display a counter which show
    how many users are currently logged in the system ? Is there any function
    call for it ?
    Or shall I define some application scoped variable to handle it ?
    james, Apr 7, 2004
    #1
    1. Advertising

  2. james wrote:

    > I am developed a web-application which support user authenication with
    > JSP/Javabean under Tomcat
    > I would like to know how I can let the jsp to display a counter which show
    > how many users are currently logged in the system ? Is there any function
    > call for it ?
    > Or shall I define some application scoped variable to handle it ?


    I don't know how to do it using JSP. However, the servlet API provides the
    HttpSessionBindingListener and HttpSessionBindingEvent interfaces which
    will allow you to track every session binding or unbinding events. Then
    you should be able to record the number of active sessions which should
    reflect the number of logged in users. Of course, this has to be updated
    with the actual user login activity:

    - When the user logs in, you remember the session id and increments the
    counter
    - When the user logs out, you decrement the counter
    - When the sessions unbinds, you decrement the counter

    Hope this helps

    Frederic
    =?ISO-8859-15?Q?G=E9din_Fr=E9d=E9ric?=, Apr 8, 2004
    #2
    1. Advertising

  3. On Thu, 08 Apr 2004 06:03:41 +0200, Gédin Frédéric <>
    wrote:

    > james wrote:
    >
    >> I am developed a web-application which support user authenication with
    >> JSP/Javabean under Tomcat
    >> I would like to know how I can let the jsp to display a counter which
    >> show
    >> how many users are currently logged in the system ? Is there any
    >> function
    >> call for it ?
    >> Or shall I define some application scoped variable to handle it ?

    >
    > I don't know how to do it using JSP. However, the servlet API provides
    > the
    > HttpSessionBindingListener and HttpSessionBindingEvent interfaces which
    > will allow you to track every session binding or unbinding events. Then
    > you should be able to record the number of active sessions which should
    > reflect the number of logged in users. Of course, this has to be updated
    > with the actual user login activity:
    >
    > - When the user logs in, you remember the session id and increments the
    > counter
    > - When the user logs out, you decrement the counter
    > - When the sessions unbinds, you decrement the counter


    Actually the simplest thing to do is - when you get a "log out" just
    invalidate the session - the listener will be called automatically.
    If the user wanders off without logging out, you still get the event
    when the session times-out.

    Bill


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    William Brogden, Apr 8, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZXN3YW5zb24=?=

    getting currently logged in user asp.net c sharp class

    =?Utf-8?B?ZXN3YW5zb24=?=, Feb 28, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    5,736
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 28, 2006
  2. iclinux
    Replies:
    0
    Views:
    365
    iclinux
    Mar 14, 2006
  3. gover

    Currently Logged on users

    gover, Jun 8, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    308
    =?Utf-8?B?U2l2YSBN?=
    Jun 8, 2007
  4. Benedictum

    Determine users currently logged in

    Benedictum, Apr 13, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    425
    Benedictum
    Apr 17, 2008
  5. Tapiwa

    Currently logged on user

    Tapiwa, Apr 22, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    477
    Milosz Skalecki [MCAD]
    Apr 22, 2008
Loading...

Share This Page