Hi I have one web application and i want to get the number of users who are currently accessing t

Discussion in 'Java' started by anu, Apr 27, 2005.

  1. anu

    anu Guest

    Hi

    I have one web application (Tomcat/Java/MySQL) and i want to get the
    number of users who are currently accessing the application.

    Also I want to get the user details of each user, which is stored in a
    database.

    How can I do this? Pls help.

    Regards
    Mary
    anu, Apr 27, 2005
    #1
    1. Advertising

  2. anu

    Guest

    Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    I'm assuming you mean you want to show something to the user like:
    "currently 27 users online!".
    This is tricky. Some user who has sent a request for a page and is now
    looking at it is not "online" in a computer sense, but he or she is
    online in the human sense. They're on the site.

    I would suggest you add some functionality to your login page that adds
    to a list of online user objects. the logout page will remove from that
    list.
    , Apr 27, 2005
    #2
    1. Advertising

  3. Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    <> scribbled the following:
    > I'm assuming you mean you want to show something to the user like:
    > "currently 27 users online!".
    > This is tricky. Some user who has sent a request for a page and is now
    > looking at it is not "online" in a computer sense, but he or she is
    > online in the human sense. They're on the site.


    > I would suggest you add some functionality to your login page that adds
    > to a list of online user objects. the logout page will remove from that
    > list.


    To the OP:
    But with this approach, if a user closes the browser without first
    logging off, then goes to bed, goes on holiday, or accidentally drops
    dead, your application will show him/her as online even though he/she
    isn't viewing your page.
    I'm afraid that because HTTP is connectionless, your problem is in the
    general case unsolvable. You'll have to make do with some approximation,
    such as counting users who have sent HTTP requests within the last 30
    minutes.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "Normal is what everyone else is, and you're not."
    - Dr. Tolian Soran
    Joona I Palaste, Apr 27, 2005
    #3
  4. anu

    Betty Guest

    Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    "Joona I Palaste" <> wrote in message
    news:d4oi73$rtk$...
    > <> scribbled the

    following:
    > > I'm assuming you mean you want to show something to the user like:
    > > "currently 27 users online!".
    > > This is tricky. Some user who has sent a request for a page and is now
    > > looking at it is not "online" in a computer sense, but he or she is
    > > online in the human sense. They're on the site.

    >
    > > I would suggest you add some functionality to your login page that adds
    > > to a list of online user objects. the logout page will remove from that
    > > list.

    >
    > To the OP:
    > But with this approach, if a user closes the browser without first
    > logging off, then goes to bed, goes on holiday, or accidentally drops
    > dead,


    So dropping dead on purpose is ok?

    > your application will show him/her as online even though he/she
    > isn't viewing your page.
    > I'm afraid that because HTTP is connectionless, your problem is in the
    > general case unsolvable. You'll have to make do with some approximation,
    > such as counting users who have sent HTTP requests within the last 30
    > minutes.
    >
    > --
    > /-- Joona Palaste () ------------- Finland --------\
    > \-------------------------------------------------------- rules! --------/
    > "Normal is what everyone else is, and you're not."
    > - Dr. Tolian Soran
    Betty, Apr 29, 2005
    #4
  5. Re: Hi I have one web application and i want to get the number ofusers who are currently accessing the application. Also I want to get theuser details of each user, which is stored in a database. How can I do this?

    Betty wrote:
    > "Joona I Palaste" <> wrote in message
    > news:d4oi73$rtk$...
    >>But with this approach, if a user closes the browser without first
    >>logging off, then goes to bed, goes on holiday, or accidentally drops
    >>dead,

    >
    >
    > So dropping dead on purpose is ok?
    >
    >


    Well, if you're going to drop dead on purpose you can at least have the
    common courtesy to logoff first.

    --
    Peter MacMillan
    e-mail/msn:
    Peter MacMillan, Apr 29, 2005
    #5
  6. anu

    kjc Guest

    Re: Hi I have one web application and i want to get the number ofusers who are currently accessing the application. Also I want to get theuser details of each user, which is stored in a database. How can I do this?

    Joona I Palaste wrote:
    > <> scribbled the following:
    >
    >>I'm assuming you mean you want to show something to the user like:
    >>"currently 27 users online!".
    >>This is tricky. Some user who has sent a request for a page and is now
    >>looking at it is not "online" in a computer sense, but he or she is
    >>online in the human sense. They're on the site.

    >
    >
    >>I would suggest you add some functionality to your login page that adds
    >>to a list of online user objects. the logout page will remove from that
    >>list.

    >
    >
    > To the OP:
    > But with this approach, if a user closes the browser without first
    > logging off, then goes to bed, goes on holiday, or accidentally drops
    > dead, your application will show him/her as online even though he/she
    > isn't viewing your page.
    > I'm afraid that because HTTP is connectionless, your problem is in the
    > general case unsolvable. You'll have to make do with some approximation,
    > such as counting users who have sent HTTP requests within the last 30
    > minutes.
    >

    Not true, if you use a SessionListener.
    kjc, Apr 29, 2005
    #6
  7. Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    kjc <> scribbled the following:
    > Joona I Palaste wrote:
    >> <> scribbled the following:
    >>
    >>>I'm assuming you mean you want to show something to the user like:
    >>>"currently 27 users online!".
    >>>This is tricky. Some user who has sent a request for a page and is now
    >>>looking at it is not "online" in a computer sense, but he or she is
    >>>online in the human sense. They're on the site.

    >>
    >>>I would suggest you add some functionality to your login page that adds
    >>>to a list of online user objects. the logout page will remove from that
    >>>list.

    >>
    >> To the OP:
    >> But with this approach, if a user closes the browser without first
    >> logging off, then goes to bed, goes on holiday, or accidentally drops
    >> dead, your application will show him/her as online even though he/she
    >> isn't viewing your page.
    >> I'm afraid that because HTTP is connectionless, your problem is in the
    >> general case unsolvable. You'll have to make do with some approximation,
    >> such as counting users who have sent HTTP requests within the last 30
    >> minutes.
    >>

    > Not true, if you use a SessionListener.


    And how is using a SessionListener magically going to turn HTTP into a
    connectionful protocol? The bottom line remains, the server is only ever
    going to know when the user sends HTTP requests. It isn't going to know
    what the user does when he/she *isn't* sending HTTP requests. He/she
    might be looking at the page returned by the server, reading it over and
    over again. OTOH, he/she could have closed the browser, gone to bed,
    gone on holiday, or dropped dead. Your server isn't going to be any
    wiser until it gets another HTTP request.
    If looking at the page counts as "being on the site" but sleeping, or
    being dead, doesn't, then the original problem remains unsolvable.
    Either you run the risk of logging the user off while he/she's still
    reading the pages, or the risk of keeping the user logged on when he/she
    doesn't have anything to do with the page any more.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "Holy Banana of this, Sacred Coconut of that, Magic Axolotl of the other."
    - Guardian in "Jinxter"
    Joona I Palaste, May 4, 2005
    #7
  8. anu

    kjc Guest

    Re: Hi I have one web application and i want to get the number ofusers who are currently accessing the application. Also I want to get theuser details of each user, which is stored in a database. How can I do this?

    Joona I Palaste wrote:
    > kjc <> scribbled the following:
    >
    >>Joona I Palaste wrote:
    >>
    >>> <> scribbled the following:
    >>>
    >>>
    >>>>I'm assuming you mean you want to show something to the user like:
    >>>>"currently 27 users online!".
    >>>>This is tricky. Some user who has sent a request for a page and is now
    >>>>looking at it is not "online" in a computer sense, but he or she is
    >>>>online in the human sense. They're on the site.
    >>>
    >>>>I would suggest you add some functionality to your login page that adds
    >>>>to a list of online user objects. the logout page will remove from that
    >>>>list.
    >>>
    >>>To the OP:
    >>>But with this approach, if a user closes the browser without first
    >>>logging off, then goes to bed, goes on holiday, or accidentally drops
    >>>dead, your application will show him/her as online even though he/she
    >>>isn't viewing your page.
    >>>I'm afraid that because HTTP is connectionless, your problem is in the
    >>>general case unsolvable. You'll have to make do with some approximation,
    >>>such as counting users who have sent HTTP requests within the last 30
    >>>minutes.
    >>>

    >>
    >>Not true, if you use a SessionListener.

    >
    >
    > And how is using a SessionListener magically going to turn HTTP into a
    > connectionful protocol? The bottom line remains, the server is only ever
    > going to know when the user sends HTTP requests. It isn't going to know
    > what the user does when he/she *isn't* sending HTTP requests. He/she
    > might be looking at the page returned by the server, reading it over and
    > over again. OTOH, he/she could have closed the browser, gone to bed,
    > gone on holiday, or dropped dead. Your server isn't going to be any
    > wiser until it gets another HTTP request.
    > If looking at the page counts as "being on the site" but sleeping, or
    > being dead, doesn't, then the original problem remains unsolvable.
    > Either you run the risk of logging the user off while he/she's still
    > reading the pages, or the risk of keeping the user logged on when he/she
    > doesn't have anything to do with the page any more.
    >

    The original poster referred to "Logging in"
    If you login, you have a Session created.
    In your web.xml you have a timeout value for a session.
    If there isn't activity (navigation etc..) associated with a given
    session in N amount of time, the session is invalidated, and is there
    are SessionListeners registered, they will be notified.
    Once notified, descrement a counter.
    kjc, May 4, 2005
    #8
  9. Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    kjc <> scribbled the following:
    > Joona I Palaste wrote:
    >> kjc <> scribbled the following:
    >>>Joona I Palaste wrote:
    >>>> <> scribbled the following:
    >>>>>I'm assuming you mean you want to show something to the user like:
    >>>>>"currently 27 users online!".
    >>>>>This is tricky. Some user who has sent a request for a page and is now
    >>>>>looking at it is not "online" in a computer sense, but he or she is
    >>>>>online in the human sense. They're on the site.
    >>>>
    >>>>>I would suggest you add some functionality to your login page that adds
    >>>>>to a list of online user objects. the logout page will remove from that
    >>>>>list.
    >>>>
    >>>>To the OP:
    >>>>But with this approach, if a user closes the browser without first
    >>>>logging off, then goes to bed, goes on holiday, or accidentally drops
    >>>>dead, your application will show him/her as online even though he/she
    >>>>isn't viewing your page.
    >>>>I'm afraid that because HTTP is connectionless, your problem is in the
    >>>>general case unsolvable. You'll have to make do with some approximation,
    >>>>such as counting users who have sent HTTP requests within the last 30
    >>>>minutes.
    >>>
    >>>Not true, if you use a SessionListener.

    >>
    >> And how is using a SessionListener magically going to turn HTTP into a
    >> connectionful protocol? The bottom line remains, the server is only ever
    >> going to know when the user sends HTTP requests. It isn't going to know
    >> what the user does when he/she *isn't* sending HTTP requests. He/she
    >> might be looking at the page returned by the server, reading it over and
    >> over again. OTOH, he/she could have closed the browser, gone to bed,
    >> gone on holiday, or dropped dead. Your server isn't going to be any
    >> wiser until it gets another HTTP request.
    >> If looking at the page counts as "being on the site" but sleeping, or
    >> being dead, doesn't, then the original problem remains unsolvable.
    >> Either you run the risk of logging the user off while he/she's still
    >> reading the pages, or the risk of keeping the user logged on when he/she
    >> doesn't have anything to do with the page any more.
    >>

    > The original poster referred to "Logging in"
    > If you login, you have a Session created.
    > In your web.xml you have a timeout value for a session.
    > If there isn't activity (navigation etc..) associated with a given
    > session in N amount of time, the session is invalidated, and is there
    > are SessionListeners registered, they will be notified.
    > Once notified, descrement a counter.


    A timeout value is inherently only an approximation. No matter what you
    choose the timeout value as, there is no law forcing users to stop
    looking at the site *exactly* when the timeout expires. Some of them
    might stop sooner, some of them might stop later. Your server isn't
    going to know for sure, it can only guess. This is what I've been saying
    all along.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "I am lying."
    - Anon
    Joona I Palaste, May 7, 2005
    #9
  10. anu

    kjc Guest

    Re: Hi I have one web application and i want to get the number ofusers who are currently accessing the application. Also I want to get theuser details of each user, which is stored in a database. How can I do this?

    Joona I Palaste wrote:
    > kjc <> scribbled the following:
    >
    >>Joona I Palaste wrote:
    >>
    >>>kjc <> scribbled the following:
    >>>
    >>>>Joona I Palaste wrote:
    >>>>
    >>>>> <> scribbled the following:
    >>>>>
    >>>>>>I'm assuming you mean you want to show something to the user like:
    >>>>>>"currently 27 users online!".
    >>>>>>This is tricky. Some user who has sent a request for a page and is now
    >>>>>>looking at it is not "online" in a computer sense, but he or she is
    >>>>>>online in the human sense. They're on the site.
    >>>>>
    >>>>>>I would suggest you add some functionality to your login page that adds
    >>>>>>to a list of online user objects. the logout page will remove from that
    >>>>>>list.
    >>>>>
    >>>>>To the OP:
    >>>>>But with this approach, if a user closes the browser without first
    >>>>>logging off, then goes to bed, goes on holiday, or accidentally drops
    >>>>>dead, your application will show him/her as online even though he/she
    >>>>>isn't viewing your page.
    >>>>>I'm afraid that because HTTP is connectionless, your problem is in the
    >>>>>general case unsolvable. You'll have to make do with some approximation,
    >>>>>such as counting users who have sent HTTP requests within the last 30
    >>>>>minutes.
    >>>>
    >>>>Not true, if you use a SessionListener.
    >>>
    >>>And how is using a SessionListener magically going to turn HTTP into a
    >>>connectionful protocol? The bottom line remains, the server is only ever
    >>>going to know when the user sends HTTP requests. It isn't going to know
    >>>what the user does when he/she *isn't* sending HTTP requests. He/she
    >>>might be looking at the page returned by the server, reading it over and
    >>>over again. OTOH, he/she could have closed the browser, gone to bed,
    >>>gone on holiday, or dropped dead. Your server isn't going to be any
    >>>wiser until it gets another HTTP request.
    >>>If looking at the page counts as "being on the site" but sleeping, or
    >>>being dead, doesn't, then the original problem remains unsolvable.
    >>>Either you run the risk of logging the user off while he/she's still
    >>>reading the pages, or the risk of keeping the user logged on when he/she
    >>>doesn't have anything to do with the page any more.
    >>>

    >>
    >>The original poster referred to "Logging in"
    >>If you login, you have a Session created.
    >>In your web.xml you have a timeout value for a session.
    >>If there isn't activity (navigation etc..) associated with a given
    >>session in N amount of time, the session is invalidated, and is there
    >>are SessionListeners registered, they will be notified.
    >>Once notified, descrement a counter.

    >
    >
    > A timeout value is inherently only an approximation. No matter what you
    > choose the timeout value as, there is no law forcing users to stop
    > looking at the site *exactly* when the timeout expires. Some of them
    > might stop sooner, some of them might stop later. Your server isn't
    > going to know for sure, it can only guess. This is what I've been saying
    > all along.
    >

    This has turned into a foolish discussion. Your opinions have no
    technical merit in the light current accepted practices, at least in the
    J2EE world.
    kjc, May 7, 2005
    #10
  11. Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    kjc <> scribbled the following:
    > Joona I Palaste wrote:
    >> kjc <> scribbled the following:
    >>>Joona I Palaste wrote:
    >>>>kjc <> scribbled the following:
    >>>>>Joona I Palaste wrote:
    >>>>>> <> scribbled the following:
    >>>>>>>I'm assuming you mean you want to show something to the user like:
    >>>>>>>"currently 27 users online!".
    >>>>>>>This is tricky. Some user who has sent a request for a page and is now
    >>>>>>>looking at it is not "online" in a computer sense, but he or she is
    >>>>>>>online in the human sense. They're on the site.
    >>>>>>
    >>>>>>>I would suggest you add some functionality to your login page that adds
    >>>>>>>to a list of online user objects. the logout page will remove from that
    >>>>>>>list.
    >>>>>>
    >>>>>>To the OP:
    >>>>>>But with this approach, if a user closes the browser without first
    >>>>>>logging off, then goes to bed, goes on holiday, or accidentally drops
    >>>>>>dead, your application will show him/her as online even though he/she
    >>>>>>isn't viewing your page.
    >>>>>>I'm afraid that because HTTP is connectionless, your problem is in the
    >>>>>>general case unsolvable. You'll have to make do with some approximation,
    >>>>>>such as counting users who have sent HTTP requests within the last 30
    >>>>>>minutes.
    >>>>>
    >>>>>Not true, if you use a SessionListener.
    >>>>
    >>>>And how is using a SessionListener magically going to turn HTTP into a
    >>>>connectionful protocol? The bottom line remains, the server is only ever
    >>>>going to know when the user sends HTTP requests. It isn't going to know
    >>>>what the user does when he/she *isn't* sending HTTP requests. He/she
    >>>>might be looking at the page returned by the server, reading it over and
    >>>>over again. OTOH, he/she could have closed the browser, gone to bed,
    >>>>gone on holiday, or dropped dead. Your server isn't going to be any
    >>>>wiser until it gets another HTTP request.
    >>>>If looking at the page counts as "being on the site" but sleeping, or
    >>>>being dead, doesn't, then the original problem remains unsolvable.
    >>>>Either you run the risk of logging the user off while he/she's still
    >>>>reading the pages, or the risk of keeping the user logged on when he/she
    >>>>doesn't have anything to do with the page any more.
    >>>
    >>>The original poster referred to "Logging in"
    >>>If you login, you have a Session created.
    >>>In your web.xml you have a timeout value for a session.
    >>>If there isn't activity (navigation etc..) associated with a given
    >>>session in N amount of time, the session is invalidated, and is there
    >>>are SessionListeners registered, they will be notified.
    >>>Once notified, descrement a counter.

    >>
    >> A timeout value is inherently only an approximation. No matter what you
    >> choose the timeout value as, there is no law forcing users to stop
    >> looking at the site *exactly* when the timeout expires. Some of them
    >> might stop sooner, some of them might stop later. Your server isn't
    >> going to know for sure, it can only guess. This is what I've been saying
    >> all along.
    >>

    > This has turned into a foolish discussion. Your opinions have no
    > technical merit in the light current accepted practices, at least in the
    > J2EE world.


    I have known from the start of this discussion that I'm being pedantic
    here. However I would not go as far as to say "no technical merit". It's
    important to understand the theory behind things, even though in
    practice we can use approximations like these to help things.

    --
    /-- Joona Palaste () ------------- Finland --------\
    \-------------------------------------------------------- rules! --------/
    "A bicycle cannot stand up by itself because it's two-tyred."
    - Sky Text
    Joona I Palaste, May 9, 2005
    #11
  12. Re: Hi I have one web application and i want to get the number of users who are currently accessing the application. Also I want to get the user details of each user, which is stored in a database. How can I do this? Pls help. Getting No: and

    On Sat, 07 May 2005 17:22:38 +0000, kjc wrote:
    > Joona I Palaste wrote:
    >> kjc <> scribbled the following:
    >>>Joona I Palaste wrote:
    >>>>kjc <> scribbled the following:
    >>>>>Joona I Palaste wrote:
    >>>>>
    >>>>>>I'm afraid that because HTTP is connectionless, your problem is in
    >>>>>>the general case unsolvable. You'll have to make do with some
    >>>>>>approximation, such as counting users who have sent HTTP requests
    >>>>>>within the last 30 minutes.
    >>>>>
    >>>>>Not true, if you use a SessionListener.
    >>>>
    >>>>And how is using a SessionListener magically going to turn HTTP into a
    >>>>connectionful protocol? The bottom line remains, the server is only
    >>>>ever going to know when the user sends HTTP requests.
    >>>>
    >>>The original poster referred to "Logging in" If you login, you have a
    >>>Session created. In your web.xml you have a timeout value for a session.

    >>
    >> A timeout value is inherently only an approximation. No matter what you
    >> choose the timeout value as, there is no law forcing users to stop
    >> looking at the site *exactly* when the timeout expires.

    >
    > This has turned into a foolish discussion. Your opinions have no technical
    > merit in the light current accepted practices, at least in the J2EE world.


    No, he's exactly right. The original poster asked to know how many people
    are _currently accessing the application_, which is impossible to
    determine due to the structure of HTTP. Sessions approximate this
    information but believing that they allow you to accurately determine the
    number of users is foolish and wrong.

    They're an approximation, at best. A fairly good one, but an
    approximation nonetheless.

    In fact, Joona suggested the very thing you did (approximate it using a
    timeout value) well before you did. It seems to me e's fully
    aware of the ways of generating data that satisfies the OP's requirements.
    Owen Jacobson, May 12, 2005
    #12
    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. iclinux
    Replies:
    0
    Views:
    369
    iclinux
    Mar 14, 2006
  2. ThazKool
    Replies:
    1
    Views:
    748
    Jon Paal
    Sep 30, 2006
  3. UJ
    Replies:
    1
    Views:
    288
  4. gover

    Currently Logged on users

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

    Determine users currently logged in

    Benedictum, Apr 13, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    437
    Benedictum
    Apr 17, 2008
Loading...

Share This Page