Java After Hours: 10 Projects Youll Never Do at Work

This chapter presented the Chat project, a fun online application that creates an Internet-based chat room using web browsers. Using Chat, you can talk with friends on the Internet using nothing more than browsers and a JSP-enabled server.

To create the chat room, Chat uses HTML, Java, JavaScript, and JSP. The HTML part presents the frames that the rest of the application displays itself ina bottom frame with HTML controls that lets the user enter comments, and an upper frame that displays the current comments and refreshes itself ever 5 seconds (and that time can be easily altered).

JSP did most of the work in the Chat project. Using JSP, you can display the current text as well as the HTML controlsa text area for comments, a text field for the user's name, and a Submit buttonthat the application needs.

The most essential item here is the JSP application object, which holds data shared among all users accessing chat.jsp. Using this object, Chat can store all the current comments, and the Java code in chat.jsp can both retrieve those comments and store them.

    Категории