Java chat

Hi everybody.

I've got a client that wants to add a chat room(s) to their site.

They don't just want a chat client that points to an mIRC server or anything like that.

It's just supposed to be chat functionality for the visitor's to their site.

Now chat rooms are not my strong point.

My understanding is that if I want to have a live chat (where you don't have to keep hitting refresh), you need to use Java (or ActiveX, but that's not a possibility since it needs to be a cross browser solution).

Question1: Is this understanding correct?

Second, my understanding is that if I use Java on the client, I will also need a Java chat server running on the web server.

The problem here is that most commercial hosting services (that I have checked with) will not allow server software to be installed.

Question2: Do I in fact need a Java chat server or is there another solution?

Any and all help/component referrals/host service referrals/comments will be most appreciated.

Thanks a lot!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

In general, if you want data to appear on the client browser without having to issue a request you want an applet.  However there are other solutions, although they aren't pretty.

1) Obviously, an applet.

2) Some sort of server push mechanism to force page updates down to the client.

3) Client pull... a timer that after X number of seconds, you go get the latest view of the pages.

These options are the result of http being a request/response protocol.  Options two and three work around that fact by sending multiple requests and/or receiving multiple responses.

You might be able to get away with dropping a link in that links you to an IRC type chat room - <a href="telnet://"> Chat here</a> or something of that nature.

If you had to choose between the three options listed above, I think that option 1 is preferable.  You get a little extra overhead for startup because you have download the applet, but once the applet is on the client machine, all you have to transfer are the messages.  Options two and three force an entire page to be sent with each update.
mayhewAuthor Commented:
helver, thanks for the comment.

That was pretty much my understanding on the client side.

What about on the server side (using the applet solution)?

Do I need a chat server?  Or can I just use applets that tie into a database?
In order to minimize traffic back and forth to clients, you should probably write some minimalist server...  I would imagine that the server would be event driven and would act something like:

while (1) {

   wait for event;

   switch (event type) {
   case NewClient:
      Add Client to ClientList;
   case ClientLogout:
      Remove Client from ClientList;
   case NewMessage:
      Send text to all Clients in ClientList;

No polling.  No tight loops.  It also doesn't have to be written in Java.  As long as you agree on a protocol it could be written in C, perl, C++, python, etc.  Writing it java would allow you to use RMI, however, and THAT would make it REALLY easy.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

mayhewAuthor Commented:
Help me out.

What is RMI and how would it make things easier?

Also, do you know of any freeware software that may already exist?

And again, if I write (or use) server side software, won't I have to have it installed on the web server (which most services don't want to do)?  Or can I just have it run in my cgi-bin directory?

Thanks for your help.
mayhewAuthor Commented:
Can anybody help with this?
A client/server app would mean using the Server's JVM. If you
know of any free hosting servlet services, let me know ;P
I think your best solution would be to use an existing Chat server such as RajChat, they give the applet classes and html to install on your server:

mayhewAuthor Commented:
Thanks for your comment dale.

But in order to install that software on my web server, I need administrative rights.

And my hosting service won't install it for me.

Maybe the question here is if I need to bite the bullet and change to a different service?
A real time capability requires that you go outside the normal operation of http.  If your service provider is unwilling to allow even fully tested and stable server processes to run then it would seem that they are not providing you with the service that you require to meet your needs.

What RMI does is allows an applet to execute a function of a java server process.  It makes data transfer and the ugliness of networking kinda go away.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
No, my answer related to only installing the applet and html on your web service and that is all. the RajChat applet uses the existing RajChat Home server, i.e.,, and not your own web server. Its a simple installation.
mayhewAuthor Commented:

As I suggested in my original statement, I can't have my clients going to a "shared" chat server.

It has to be available to my client's audience only.

"It's just supposed to be chat functionality for the visitor's to their site. "

Perhaps I didn't say it very well, but the intent was to have a service that only visitors to their site could access.

I have awarded the points to helver, but I realize that you may have misunderstood the question.  Therefore, if you have a solution that will help me, I will create another question for you.

But linking to someone else's chat server or installing chat server software will not answer my question.

Otherwise thanks for your comment.  I appreciate your effort.
mayhewAuthor Commented:

That is pretty much what I've decided.  I'm going to begin researcing a new service.

Can you point me in the right direction to begin studying RMI?  Books or sites?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.