• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Viewing a list of all active users

 
Rajesh Rajaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I have a requirement to list all the active sessions in the application. Is there any api or any other way of getting the active session. Its for the Administrator of the application.

regards

Rajesh
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sessions or users? Your subject and thread body don't really ask the same question.
 
Paul Clapham
Sheriff
Posts: 20983
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's sessions you want to keep track of, then an HttpSessionListener sounds ideal. Documentation says

"Implementations of this interface may are notified of changes to the list of active sessions in a web application."
 
Rajesh Rajaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,

Its with session, I need to show a report. Which will say Person X is online or Offline.

can we extract the username from the session with the application.

regards

Rajesh
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, well, not that I know of. I mean, it would be a security breech for one user session to be able to see any other user's session, regardless of the user's role.

How this is usually acomplished, from my personal experience, is to use HttpSessionListener. Basically, when a user logs in you would want to either store a flag in a database that says that user is logged in or store something in Application scope. When the user logs off and/or the user's session is invalidated, change said flag.

You can do this with an HttpSessionListener. Look it up.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a JSP question, so moved to the Servlets forum.
 
Rajesh Rajaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Greg, It won't be a security breach, Since adminstrator is going to view the information.

I will try HttpSessionListener.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rajesh Rajaram:
Thanks Greg, It won't be a security breach, Since adminstrator is going to view the information.

I will try HttpSessionListener.


What I meant was if user a was able to see user b's session for whatever reason, you wouldn't be able to limit that to a role based situation. It wouild either be all or nothing, so it wouldn't be a secure thing to have availabel in the API, imho.
 
Rajesh Rajaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have about 1000 users worldwide, suppose if we need to perform a maintence work like restarting some of the services, deploying new build , it should not destroy their work.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There used to be a sessionContext object but it was deprecated for the reasons Gregg listed.

SessionListeners make it easy to implement yourself.
I wrote a little sample app that does this.
http://simple.souther.us/not-so-simple.html
Look for Session Monitor.
 
Rajesh Rajaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben, Appreciate your Input.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic