Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6347225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:10:23+00:00 2026-05-24T21:10:23+00:00

I am new to comet. can anyone tell me how to implement a web

  • 0

I am new to comet.

can anyone tell me how to implement a web based chat using comet in java ( Any webtechnologies Eg. JSP ,servlet struts etc. ) ..??

Any help is greatly appriciated.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:10:23+00:00Added an answer on May 24, 2026 at 9:10 pm

    Set up a basic Struts2 application using maven (Struts2 web site).

    Add the spring plugin.

    Create a service Object which will hold a log of chat messages (List<Map<int, String>>). Each message added adds a new map to the list with an index 1 greater than the previous with the submitted message. If the list reaches a certain size delete the lowest messages to keep the max size. (There are better data structure’s for this but you can figure that out).

    Add the Struts2-JSON-plugin.

    Create two json actions (read how to use the Struts2-JSON-plugin). SendMessage and GetMessagesSince Action. Also create a basic action to create the chat page (I would also use the conventions plugin).

    SendMessage will have a setter for message. It would be a good idea to have a getter for Status (returns “success” or “failure”).

    GetMessagesSince has a getter for Messages which will return a list of {int, Strings}. It will have a setter for lastMessage(int).

    Now for the WebPage. At this time simply use short polling (call in a loop after a short break) to get messages greater than ‘lastMessage’ (which will start at zero). Using jQuery magic you’ll get back the response from GetMessagesSince (which will start the chat client off with a little bit of history, if there was any) You will use the last message in the list to derive the new value for GetMessagesSince.

    Now with some concurrency magic you can implement long polling. You can also add dates to the messages so people know how old the conversations are. You can also add different message groups, by creating Maps of your chat queue, ie: Map<String, List<Map<int, String>>> where I’ve chosen string in this case to identify your chat room.

    If you’re serious, I might even create a demo (It’s easier than it sounds).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using web service asmx, whenever a new request comes, all objects will
Every new web service you create using visual studio comes with a predefined namespace
Can any one tell me that why delay happen when I run this script
Can anyone tell me how i can manually edit my naming convention of my
I have a web app that is using Bayeux to handle Comet connections. I
I was trying to write a sample chat application using Web Services in .net
Can anyone tell me how I can animate different images? I want to animate
I was wondering if anyone can tell me if MongoDB or CouchDB are ready
Can anyone tell me..... When a .txt file is picked up in a pipeline
please can anyone show me how to implement a countdown timer for starting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.