Magnificent Chat - Applet / Servlet Communication
This was my examination assignment of the Internet Programming 2 - course.
Magnificent Chat v1.0 is a Web application that uses the HTTP protocol to send and receive messages. The main advantage of using a HTTP high-level connection compared to low-level socket connections, is the availability behind firewalls.
- On the server-side I use a servlet to save incoming client messages to their inboxes which are stored in client sessions.
- On the client-side I use an applet to send client messages and continously poll/collect messages from the client's inbox stored in the client's session on the server-side.
Four Types of Messages
There are four kinds of messages a client(i.e. Web browser running the applet) can send to the servlet. These are:- A message telling the servlet the client has logged in.
- An ordinary message.
- A private message.
- A message telling the servlet the client has logged out.
At a login message a session and an inbox object are created. The inbox is then put in(bound to) the session, and the user together with his session object is put in a collection class.
At a ordinary message the message is put in other online clients inboxes, i.e. broadcast is simulated.
At a private message the message is put in the recipient's inbox, i.e. unicast is simulated.
At a logout message the client's session and his inbox is invalidated and he is removed from the collection class.
Assignment Description
This examination assignment didn't have any restriction except one: It had to make use the techniques used throughout this course.
Apart from that one was free to create any kind of application.
My goel with this assignment was to implement an applet communicating with a servlet without forcing users to open any ports in their local firewalls.
I achived this by using HTTP and simulate a bidirectional connection.
Chat Files and Screenshoots
Here are some screenshots of the chat.
Try the Magnificent Chat Applet
