tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Glen Vermeylen" <glen.vermey...@gmail.com>
Subject Re: Retrieve list of all sessions
Date Thu, 08 Mar 2007 12:09:41 GMT
Thanks for the idea, putting a sessionbindinglistener on the session each
time a user logs on is a much cleaner approach.
Locally it seems to work nicely and I can delete the sessionlistener from
web.xml.

2007/3/8, albrecht andrzejewski <albrecht.andrzejewski@ema.fr>:
>
> I actually track my connected users with this code:
>
> public class MySessionManager{
>      public static Set <String>  connecteds;
>
>      /** Creates a new instance of MySessionManager */
>
>      public MySessionManager() {
>
>          connecteds = new java.util.HashSet();
>
> and i use this method to add an entry for each new session created
>
> public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
>
> connectedPlayers.add
> ((String)httpSessionBindingEvent.getSession().getAttribute("login"));
>
>
>      }
>
> I'm new to J2EE/servlet and i have not tested with multiple users, and
> i was not thinking about the concurrency.
>
> Do i need to instantiate my set with something like:
> Collections.synchronizedSet( new java.util.HashSet())
>
> Or is it better to use directly the old hashtable ?
>
> Best regards.
>
>
> Quoting Glen Vermeylen <glen.vermeylen@gmail.com>:
>
> > We use Tomcat 5.5.20.
> >
> > I actually have no synchronization in place whatsoever. I will change to
> > hashtable and see if it solves the problem.
> >
> > Thank you.
> >
> > 2007/3/7, Caldarale, Charles R <Chuck.Caldarale@unisys.com>:
> >>
> >>> From: Glen Vermeylen [mailto:glen.vermeylen@gmail.com]
> >>> Subject: Retrieve list of all sessions
> >>>
> >>> I've created a management screen which lists all currently
> >>> logged in users. This list is kept as a hashmap and is kept
> >>> "in sync" with reality in the following way:
> >>
> >> A HashMap is unsynchronized; does your logic provide the necessary
> >> synchronization for insertions, deletions, *and* retrievals?  If not,
> >> switching to a HashTable might resolve your problem.
> >>
> >> Or then again, it might just be a bug, but you didn't tell us the
> >> version of Tomcat you're using, so searching bugzilla would be rather
> >> tedious.
> >>
> >> - Chuck
> >>
> >>
> >> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
> PROPRIETARY
> >> MATERIAL and is thus for use only by the intended recipient. If you
> >> received this in error, please contact the sender and delete the e-mail
> >> and its attachments from all computers.
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
>
>
>
> ----------------------------------------------------
> Ce message a ete envoye par le serveur IMP de l'EMA.
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message