The purpose of the exercise: to build a site that allows you to enter the chat room and send messages.
Topics: Servlets (ServletContext, Dispatcher), Seats and / or Cookies, Ajax / JSON
The site does not use a database.
A user registers his name, clicks a button and enters Chat.
Total sign-in page:
• Form contains text input for user name input.
• A button to enter the chat room
CHATROOM page includes:
• Title Title: Welcome <Username> when <Username> contains the username
• A form with text input and a button to send a chat message
• Exit button from chat
• Chat: Content of all sent messages (sender name and message to each)
Avoid sending empty messages (including spaces only).
This page is automatically updated every 30 seconds without loading the page again. You must use Ajax and implement a Servlet that returns the chat content in JSON format. In addition, the page will automatically switch to the login page, if the user is no longer logged in. This can happen when the user opens two pages and logs off.
There are no exact instructions on the number of pages but in general the user must be allowed to browse between pages by buttons or links of the site itself and not based on the buttons of the browser (for example the error page requires a button to continue surfing).
Must be exercised:
• Login to chat
• Exit chat
• sending a massege
• Receiving the client chat and updating the page (Ajax / JS + JSON servlet)
• Input validation
Part of the purpose of the exercise is to divide the code into servlets. There are no instructions on the servlet number, but you are required to implement at least 2 servlets, for example, for login / exit, and for the chat itself.
Avoid writing long HTML / css / js code within Java / Servlet. It should be used in include of external html files (this is also much more convenient and readable).
You can use [login to view URL] () to divide roles between servlets: for example, it is common to define a servlet whose function is to pass requests to different servlets. Of course, you can store information in session cookies, servlet context. Note that there may be problems of synchronized sections if you use the servlet context.
When a user logs in to chat, check that they already have their name on the Sign In page. If the user is not recognized (or exported), they will be sent directly to the login and will not be able to see the chat page.