This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Inspiration and help needed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

Inspiration and help needed

Jon Kidd
Greenhorn

Joined: Oct 11, 2002
Posts: 29
Hi all,
Am after some help with a chat application I am building. Basically I am having real problems with showing a list of all the users currently logged in. Currently I have a bean for each user that is then also added to an application session bean which shows all the users, I have run into big problems though trying to remove a user from this application session bean should a user just close their browser so I think I'm going back to the drawing board.
What is the best way for coding this ? I was thinking maybe, use a servlet to 'log' a user in, create a bean for them and then add that bean to a bean containing a list of all the users, I could then use the session listener to keep check of when a user disconnects and the remove that user from the list of logged on users ? Would the bean containing the list of users be available for all the users to see ?
I'm sure this must of been done before and I've searched and searched but I'm really looking for a definitive guide as to how I should approach this whole thing before I jump in and start trying to code it all again.
Any ideas or input very gratefully received.
Jon
Dave Comeau
Greenhorn

Joined: Jun 14, 2002
Posts: 27
Are you using an HTML based client? You really need a client with state.
I wrote a Flash based client that communicates with a Java chat server.
The server keeps up with who's connected by sending out pings to the clients. If the client doesn't pong back, it's dropped.
I'm sure you could write a Java client that does the same thing.
An HTML based client won't be able to do this, without some horrible refresh hack.
Jon Kidd
Greenhorn

Joined: Oct 11, 2002
Posts: 29
Not sure how that would react to clients behind firewalls though ?
I've sort of now kludged something together using Applets on the browser and then calling the destroy method which in turn calls a servlet on the server removing the client from the list of logged on users. Difficult work though then trying to design a site around an applet that mustn't be closed
I'm sure there are easier ways but I have yet to see a simple and concise explanation.
Cheers
Jon
Dave Comeau
Greenhorn

Joined: Jun 14, 2002
Posts: 27
Yeah, I don't think the client side destroy can be depended on. What happpens when the client's machine crashes or is unplugged?
As for firewalls, those ports are firewalled for a reason. So if the chat clients doesn't work, the sysadmin doesn't want people chatting. I know AIM steps around this and uses port 80, which pisses most sysadmins off.
Jon Kidd
Greenhorn

Joined: Oct 11, 2002
Posts: 29

As for firewalls, those ports are firewalled for a reason. So if the chat clients doesn't work, the sysadmin doesn't want people chatting.

So an uptapped market then
Cheers
Jon
Arindam Bose
Greenhorn

Joined: May 11, 2009
Posts: 4
HI Jon,

I am creating a web application using JSP and Servlets which enables users to chat using JMS. I need to know how to know the solution to the following situation:


user1 and user2 are chatting with each other.
when user1 sends a message to user2 I use JMSQueue to insert the message at the server end.
But user2 retrieves the message from the queue only when I manually refresh the page or set the page to an autorefresh using a timer.

Please suggest how to overcome this drawback ie. how can I retrieve the message at the client end which is user2 only when the user1 submits the message ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

"ones ones", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

And yo may want to consider starting a new thread, as this one is from 2003.
Arindam Bose
Greenhorn

Joined: May 11, 2009
Posts: 4
Thanks for the suggestion David......
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inspiration and help needed
 
Similar Threads
Issue in session manegement
Removing Users Sessions On Server ?
Help on Using Stateful Session Beans (SFSB) the right way
Message exchange between session bean instances, is it possible?
custom security and HttpSession access