chat application


I need to implement online chat in my web application?
Please suggest some example or approach ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You'll want to take a look at Node.js or SignalR.
Do you want something simple in JSP?
RockingAuthor Commented:
yes jsp and servlet
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

There are some already written. Look at   
But, if you want something really simple, we could write some code here. What are your requirements?
RockingAuthor Commented:
a simple program with user can do online chat with the administrator like that in experts exchange
I found time to start on this. I coded it the simplest way that I could think of doing it. There certainly is a lot more to do.  Right now, it is all on one page.  Later the chat can be in a separate window that refreshes  itself or uses AJAX. Later we can add a HttpSessionListener to remove invalid sessions from the map. Or the admin could remove old chats manually. Later we could use usernames for display. Maybe later we might think about thread safety if its a problem. Please copy, paste, and test.
<%@ page import="java.util.HashMap" %>
<%@ taglib uri="" prefix="c"%>
  HashMap<String,String> map = (HashMap<String,String>)application.getAttribute("map");
  if(map == null){
                   map = new HashMap<String,String>();
  String id = session.getId();
  String message = request.getParameter("m");
  String userId = request.getParameter("i");
  if(userId != null && !"".equals(userId.trim()))id = userId;
  if(message != null && !"".equals(message.trim())){
		String chat = map.get(id);
		chat += message + "<br/>";
<c:if test='${ == "password"}'>
	<c:forEach items="${map}" var="item">
		${item.key} = ${item.value} <br/>
<c:if test='${ != "password"}'>
<c:if test='${ == "password"}'>
  Admin, enter id you want to talk to<input type="text" name="i">
  Type message<input type="text" name="m">
  <input type="submit">
    If you are admin Enter admin password<input type="text" name="ad" value="${}">

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.