i need to calculate all the user who are connected to the server.and then i need to send this this total to all the users who are connected at that time.please can some body help me with java codes.i am totally new to java. thanks in advance.
Again, if you're just starting out with programming, Java, Servlets and/or JSP, this project might be a little too advanced.
In a nutshell, I bind a map to context scope that holds references to all the active sessions. When someone logs in I bind a userBean object to their session and then add their sessionId to that map. I use a SessionListener to insure that the sessions are removed from the map when they're invalidated.
Note: This approach will not work in a clustered environment as it is.
In my opinion, using JSP for anything but a view tier would be the wrong way. In our CodeBarn there are some very simple example apps that show how to use the Model, View, Controller (MVC) pattern in a Java web application.
The project on my site will be easier to understand if you make sure you understand MVC before looking at it. This article by Bear Bibeault (one of the JavaRanch sheriffs) is a nice introduction to the concept.
subject: help needed for java to calculate number of user online