This article presents an AJAX (Asynchronous Java and XML) project done with straight AJAX. That means this application will not be using any library or toolkit—it will just be you and JavaScript! Here we'll build ourselves a nice little multiuser, multiroom chat application, much like the Yahoo! chat rooms. Even better, we'll build this application using Struts on the server to make it that much more interesting!
Chat rooms have been with us for a very long time now. In fact, it is chat rooms, those gathering places where you can talk in real time with your fellow computer users, that draw many people to the Internet in the first place (email tends to be the biggest draw, but chat rooms are not too far behind for many people).
If you think about what a chat room application must require, it becomes clear that we'll need a server component. There has to be some broker in between all the chatter that deals with keeping track of the various chat rooms available, who is logged in and chatting in what room, and those types of system-level considerations. More important, though, is some arbiter of messages—a way for all the people currently chatting in a given room to see the various messages.
In a "real" chat application, such as those you might find on AOL, for instance, it is likely that the server actually pushes new messages out to the users in the room. That way, there is no delay between when someone says something and when everyone else in the room sees it.
If you were going to build a purely HTML-based chat application, as we are about to do, you'd have to consider all of these points. However, because the Web is based on a pull model of client-server interaction, ignoring things like applets and such, you clearly need to go about things a little differently. Could you have a meta refresh tag on a page that periodically asked the server for any new messages? Yes, but then you would be redrawing the entire screen each time, which would be rather inefficient, especially if you built it with something like JSP (JavaServer Pages) or another dynamic rendering technology where the server would be responsible for that redrawing.
There must be a better way, and of course there is: AJAX!
The AjaxChat application will have a number of requirements based on these, and a few others, as follows:
This should be a fun project! Let's now figure out how we are going to accomplish all that we have set out for ourselves.
Very good.By Anonymous on September 15, 2009, 10:32 pmVery good.
Reply | Read entire comment
source codeBy Anonymous on July 27, 2009, 9:24 ami need this project source code............how to get it tell me
Reply | Read entire comment
Great, I love this topicBy Anonymous on May 3, 2009, 11:25 pmGreat, I love this topic
Reply | Read entire comment
Not able to download source codeBy Anonymous on March 25, 2009, 8:17 amNot able to download source code, it says page not found message.
Reply | Read entire comment
goodBy Anonymous on February 23, 2009, 4:09 amgood
Reply | Read entire comment
View all comments