aspose file tools*
The moose likes Servlets and the fly likes Chat server with servlet..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Chat server with servlet....." Watch "Chat server with servlet....." New topic
Author

Chat server with servlet.....

Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Hello all,
In case the chat server is servlet based then,
1.the client applet opens a connection using url and urlconnection objects to servlet and passes login info.
2.the client applet then is ready to send messages and for each message that it sends, the urlconnection is again made to servlet.
3.the servlet on the other end stores this login info and messages, say in a hashtable.
4.the client applet then in its run() makes continuous request say every 3 seconds or so to the servlet (again opening a urlconnection) and servlet gets the stored message if any, and responses back.
a. Am I correct? Or is there a better way?
b. I have done as explained above and observed that for each message that a client sends, the doGet() of servlet is invoked and the response is made. It works. But how will the servlet handel the situation if there are say 100 clients sending messages?
c. Any comments or advice is seriously expected.
KB

[This message has been edited by Kruger Brent (edited January 25, 2001).]
Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
No response???
KB
rajani peddi
Ranch Hand

Joined: Nov 27, 2000
Posts: 73
hi Kruger Brent,
I guess that the server must be multithreaded to handle all the clients at the same time. You can start a new thread in the server each time a client makes a connection. I am not sure of this.... just my guess. i would appriciate if someone elaborates on this.
Thank you
rajani
Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Thanks Rajani. But I dont think we require a thread to be spawned when it is with servlets because it has a built in process to spawn a thread for every client.
Even I hope some experts to disscuss here.
KB
Kruger Brent
Greenhorn

Joined: Jan 05, 2001
Posts: 26
Moderators/experts....respond!
KB
[This message has been edited by Kruger Brent (edited January 30, 2001).]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

myself, i would like to have your code. I cant seem to get an applet to talk to a servlet in Netscape only in IE.
my email is rmtwede@gotoworld.com


SCJP
Visit my download page
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
As I just posted in one of the other Chat threads, I have a servlet based chat in my Java Developer's GUide to Servlets and JSP - There is also one in Hunter's book.
With a servlet base you let the servlet container worry about the Threads.
There is no problem with handling 100 users - the key is to remove the responsibility of tracking the different chat rooms and messages from the servlet and put it in a separate object with appropriate synchronization.
Bill

------------------
author of:


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chat server with servlet.....
 
Similar Threads
how do I know when client closes the browser ?
Chat application
help on server/client design
strange problem with swing based windows
URLConnection problem