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 <[EMAIL PROTECTED]>:
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 <[EMAIL PROTECTED]>:
> 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 <[EMAIL PROTECTED]>:
>>
>>> From: Glen Vermeylen [mailto:[EMAIL PROTECTED]
>>> 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: [email protected]
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
----------------------------------------------------
Ce message a ete envoye par le serveur IMP de l'EMA.
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]