wood burning stoves 2.0*
The moose likes JSP and the fly likes help needed for java to calculate number of user online Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "help needed for java to calculate number of user online" Watch "help needed for java to calculate number of user online" New topic
Author

help needed for java to calculate number of user online

hafiz ijaz
Greenhorn

Joined: Jan 08, 2008
Posts: 2
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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm not sure what you mean by "help".
If you're really new to Java, servlets, and JSP, this project might be a bit over your head.

You might be better of starting with a good book or web tutorial that introduces the building blocks of a Java web application in an order that makes sense to someone learning from the ground up.

Once you get a feel for the environment, you'll probably be able to come up with several ways of doing this.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
hafiz ijaz
Greenhorn

Joined: Jan 08, 2008
Posts: 2
[thanks BEN!
I did started learning.but i wanted the idea from some one who can give me some clue which class i shall use.my idea is to start with.


.i wanted to make sure i am not going wrong way.



[BSouther: Added UBB CODE tags]
[ January 09, 2008: Message edited by: Ben Souther ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

The approach will depend on what you mean by active user.

If you roll your own login, this is pretty easy to do.
I have a demo application on my site that does exactly what you're trying to do.
http://simple.souther.us/not-so-simple.html
Look for SessionMonitor.

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.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by hafiz ijaz:

I wanted to make sure i am not going wrong way.


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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help needed for java to calculate number of user online