• Post Reply Bookmark Topic Watch Topic
  • New Topic

What do you think about my techniqe ?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all.
I was thinking about how websites displays information like :
There are now 400 online guest and 40 registered user.
I am thinking about this implementation :
I developed a session listener that has a counter (this counter increases when any user entered the application).
also, I developed singleton class that has tow counters :
the first, is the previous counter in the previous listener.
the second, is a counter presented the number of registered users.
when a user has done a succesfull login, the singleton decreases the first counter and increases the second counter.
what do you about this approach ? does it has wrong points ?
can I use it in real and working application ?
thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35737
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
I didn't see any piece about decrementing the counters. I assume you would subtract from the counter when a session is invalidated or timed out.

Your approach is fine. Just keep in mind that the number of users is a bit overstated. This is due to the fact that a session can be active for a while after the user has left.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
in the singleton class, the first counter will decrements 1 when a succesfull login has made and increases the second (not decreases as I wrote)

I assume you would subtract from the counter when a session is invalidated or timed out.

how can I know that ??
thanks for quick response.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can implement that in your sessionDestroyed() method of HttpSessionListener.

And I think for registered user you dont need a counter. yeah ofcourse if it is about registered online users then its fine.

one more thing you mentioned above that you developed a Listener. why not use HttpSessionListener provided by the vendor. Is there any problem with that???
[ September 28, 2004: Message edited by: adeel ansari ]
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

why not use HttpSessionListener provided by the vendor.

actually, I am using it.
when I say : I developed a listener, I mean I coding a listener.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OOppps, I forgot something.
imagine this scenario :
when a user (guest or registered) close his browser, how could I know that in order to decrement a specific counter ??
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by John Todd:
OOppps, I forgot something.
imagine this scenario :
when a user (guest or registered) close his browser, how could I know that in order to decrement a specific counter ??


Session time out feature will be useful. When the session timeouts sessionDestroyed will be invoked. There will time gap between the user closing the browser and session timing out.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for the accuracy you can use some javascript function on browser window close.

But again when clients power shuts down it would be done using sessionTimeout.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35737
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"for the accuracy you can use some javascript function on browser window close"
Netscape doesn't support this. But the default session timeout is 30 minutes. So after 30 minutes the session will be destroyed anyway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!