• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Viewing a list of all active users

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sessions or users? Your subject and thread body don't really ask the same question.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ben, Appreciate your Input.
 
There's a way to do it better - find it. -Edison. A better tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic