chat application

Posted on 2014-08-08
Last Modified: 2014-08-14

I need to implement online chat in my web application?
Please suggest some example or approach ?
Question by:Rocking
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    You'll want to take a look at Node.js or SignalR.
    LVL 27

    Expert Comment

    Do you want something simple in JSP?

    Author Comment

    yes jsp and servlet
    LVL 27

    Expert Comment

    There are some already written. Look at  
    But, if you want something really simple, we could write some code here. What are your requirements?

    Author Comment

    a simple program with user can do online chat with the administrator like that in experts exchange
    LVL 27

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Suggested Solutions

    Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
    This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now