Click to See Complete Forum and Search --> : How can i write a chat room on the web?


slho7
February 23rd, 2000, 09:32 PM
hi,
i want to ask how should i begin to write a chat room on the web? is java applet the most suitable candidate? any other choices?
and where should i find some references or source code example to start my coding? thanx. have a nice day.
calvin

DHunter21
February 24th, 2000, 06:57 PM
There are plenty of freely available chat applets available on the web already. Check of JavaBoutique or jars.com.

There are a number of ways that you can write a chat applet yourself.
1. Use HTML-Servlet Communication
2. Use Socket-Servlet Communication
3. Use RMI-Servlet Communication
4. Use Socket-Custom Server Communication
5. Use RMI-Custom Server Communication.

If you're new to java, stay away from RMI (Remote Method Invocation)for a while. Basically its away to call a method that resides on a server from a client.
If you want to use your chat applet with a server program such as apache or JWebServer, then you might want to learn about servlets. Servlets are routines that occur on the Server, when called by a client (usually an applet). They are very similiar to CGI scripts, except better in almost every way.

Probably the easiest way to get up and running is to design your own chat server. This would replace the web server in the step before. Writing your own chat server is actually quite simple. In fact it can be done in 30-40 lines of code (possible much less). Essentially this chat-server would be sitting on your computer listening to all requests on a particular Socket number. When a request comes in, the server just broadcasts that message to all clients currently connected to the server.

I think there is code at Oreilly's site. Look under the "Servlet Programming" book by Jason Hunter. (Actually everyone should buy this, it is a fantastic book). Try this:
http://www.servlets.com/jsp/examples/ch10/index.html.

Hope it helps

Dustin