• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple Chat Application with JSP/ Servlets

 
Yasothar Arulnayagam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm learning JSP/ Servlets and I would like to create a simple Chat Application where users can just send and get messages. Will be pleased if I can get some help with the Design, (Like a step by step instruction) on how to do it. I don't need the code. Just the instructions. Just want to put my knowledge to work. That's all. Thank you in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You first. What have you come up with so far?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Time to make a diagram or two! - not code but the basic data flow.

Start with blobs representing the various participating entities - draw lines representing the flow of data between them - "play computer" tracking how chat messages move around.

If you want to get formal about it, study the Unified Modeling Language for ideas, but blobs and lines will work.

Bill
 
john wutka
Ranch Hand
Posts: 31
 
Yasothar Arulnayagam
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response guys. My question at this point is How am I going to pass the chat message from a session user to another. Can I use the context to inter change the "Chat message"? Session Attributes will definitely not work, I understand that. And how am i going to force the Chat message receiver to force refresh the page and get the message. I'm kind of new to this area, so kindly correct my mistakes. Thank you.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yasothar Arulnayagam wrote:My question at this point is How am I going to pass the chat message from a session user to another.


You aren't. You're going to wait until the recipient of the message asks for it.

And how am i going to force the Chat message receiver to force refresh the page and get the message.


You aren't. The client (what you call the "Chat message receiver") is going to refresh itself from time to time and ask the server if there are any messages for it. If there are, the server will return them and the client will display them.

I'm kind of new to this area, so kindly correct my mistakes.


Your main mistake is thinking that the server will control the behaviour of the clients. That isn't how web applications work, the clients are in control. They decide when to send requests and the server replies. The server never decides to contact a client, because it can't. All the server does is wait for requests and then respond to them.
 
Guy deLyonesse
Ranch Hand
Posts: 200
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Your main mistake is thinking that the server will control the behaviour of the clients. That isn't how web applications work, the clients are in control. They decide when to send requests and the server replies. The server never decides to contact a client, because it can't. All the server does is wait for requests and then respond to them.


Unless you use AJAX Push. I've seen some nifty demos for chat programs and online auctions that use AJAX push to update the client browser, because a persistent DOM connection keeps them in sync.

If I were building a chat application like this, I'd use JSF/ICEFaces to build it. ICEFaces uses AJAX to handle the partial submits and pushes.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He's said that he's doing this to learn JSP and servlets. Suggesting an alternate technology and something as advanced as JSF is not helpful at this point.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic