wood burning stoves*
The moose likes Servlets and the fly likes Simple Chat Application with JSP/ Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Simple Chat Application with JSP/ Servlets" Watch "Simple Chat Application with JSP/ Servlets" New topic
Author

Simple Chat Application with JSP/ Servlets

Yasothar Arulnayagam
Greenhorn

Joined: Mar 12, 2012
Posts: 2
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

Joined: Jan 10, 2002
Posts: 60752
    
  65

You first. What have you come up with so far?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12759
    
    5
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

Joined: Apr 14, 2011
Posts: 31
Here is interesting link

http://stackoverflow.com/questions/2272463/chat-application-using-jsp-and-servlets
Yasothar Arulnayagam
Greenhorn

Joined: Mar 12, 2012
Posts: 2
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Apr 12, 2011
Posts: 200

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

Joined: Jan 10, 2002
Posts: 60752
    
  65

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.
 
wood burning stoves
 
subject: Simple Chat Application with JSP/ Servlets
 
Similar Threads
Chat Application
need resource
APIs/Strategy to be used in developing web-based chat Application using Servlets.
need help regarding this one
chat application like facebook