Okay, I think I understand what you are trying to do, will this work:
On the Servlet side, have a static class (a class w/ static counter and static method) something like this (change the array to a vector to support unlimited users, i'm using an array because you said that's what you were using, and to simplify the example):
public class UserCounter {
static String[] users = new String[10];
int iCurrentUser = 0;
static void addUser(String user){
users[i++] = new String(user);
}
static String[] getUsers(){
return users[];
}
}
call UserCounter.addUser() from the Servlet that authenticates the user when they login, since the username ought to be available then.
Then, you can have another servlet that the client calls (on a timer or something) that gets the list of users from the server.
Regards,
Meredith Shaebanyan
|