Chat Applet Communicating with a Servlet

September 11th, 2006

When coding a Chat application in Java that should be available on the Web a good choice is to have an applet communicating with a servlet.

Although sockets can be used, a better alternative is to use a high-level connection with HTTP. This will work even for applets running behind firewalls since most firewalls allow HTTP connections. The applets are simply used as browsers sending messages with the POST method and retrieving messages with the GET method.
Because HTTP is a unidirectional protocol, and a chat user of course should be able to see incoming messages at once, bidirectional communication has to be simulated. This is done by having the applets continuously poll for new messages. There will be some overhead of course, but unlike more common CGI programs a servlet no longer has to wait as the server launches a CGI program to handle each of its repeated requests.

Here is a description of a Chat Applet / Servlet application I’ve created which I modestly named: Magnificent Chat: Applet/Servlet Communication.
At the bottom of the description page you can download the .java files and try out a working example.

Entry Filed under: Java

Bookmark with del.icio.us

Digg it?

22 Comments Add your own

  • 1  |  November 15th, 2006 at 2:18 pm by Jdog

    Just got the chat up and running in my lan. Works great! Planning on redoing your PrivateDialog class to implement the behavior of chat rooms. I might be sending a few mails if I get stuck, if it’s ok?

  • 2  |  November 21st, 2006 at 11:48 pm by Martin

    Had some thoughs on implementing chat rooms myself, but I haven’t got the time…yet.

    Sure, send me a message if you get stuck. Either use my contact page or send me a mail. Good luck.

  • 3  |  December 7th, 2006 at 10:07 am by Borat

    Think I will follow Jdog and try to some code changes to implement chat rooms that allow for more than 2 users. Maybe a admin page too, to be able to do some changes at a higher level.

    Been looking for free Java Chat code to use for a client project, but without any luck so far. I’ll let u know how it goes…

  • 4  |  January 14th, 2008 at 7:40 am by PenOrdennySet

    Greetings Very good web site. I loved it. Found invaluable information. Just what I was looking for :-) Regards and best wishes
    Best jewelry links!

  • 5  |  January 15th, 2008 at 12:41 am by Chidwizzits

  • 6  |  February 28th, 2008 at 9:08 pm by avenged fan sevenfold

    end avenged sevenfold sevenfold avenged the

  • 7  |  March 24th, 2008 at 10:46 pm by diofsdepapofs

    Do you know if some company use the same marketing concept as Webkinz?

    I’m writing a few articles right now and want to get some info and opinions.

  • 8  |  April 6th, 2008 at 12:52 pm by lionsiy

    Hi all gays!!!
    I’am nebie this forum.

  • 9  |  April 17th, 2008 at 4:11 pm by agelleplish

  • 10  |  April 19th, 2008 at 11:01 am by gewprearo

    so, A bird may be known by its song. the hunted knife homemade tattoo guns desert eagle clip hk 416 carbine giant bowie knife boker tree brand knife trade paintball gun forputer parts winchester 94 illinois sesquicentennial

  • 11  |  April 25th, 2008 at 6:35 pm by Volder-newsIS

    Hi

    Test:)

    G’night

  • 12  |  April 26th, 2008 at 1:12 pm by artkolkovk

    Hey guys I had an old laptop running XP Pro. A couple of weeks ago, every time I would connect to the internet via DSL or wireless, the hard drive light would come on - as if it were writing something to the hard drive. It would cause IE to run slower than dial-up. I looked in task manager and although the CPU usage was high, there didn’t seem to be a process listed that was using it. I used LavaSoft Adaware to scan on a regular basis as well as Norton 2005. I eventually gave up and bought a new laptop (Vista Home), which now has the same problem. It is obviously related to something that I copied over to the new computer from the old computer. But the things is, Norton Internet security isn’t picking up a virus. I used it to scan everything before copying it on to the new computer. Has anyone heard of such a thing or had the same problem? I’d much rather be able to find and remove the problem rather than restore.

    Thanks!

  • 13  |  May 1st, 2008 at 8:24 am by mody

    supra Modalert Place to buy
    cheap buy modalert

  • 14  |  May 10th, 2008 at 5:46 am by DancerFF


  • 15  |  May 17th, 2008 at 3:55 am by Zelotelty

    while levitra sum fit Viagrums moribund wild alarming to draft phentermine last tell love force efface regarding pump car stress

  • 16  |  May 31st, 2008 at 5:21 pm by karSpemajakfake

    fake rolex watches
    cheap fake rolex watch
    how to spot a fake rolex
    how to spot a fake rolex
    http://www.imeem.com/people/5lo02vg/blogs/2008/05/31/rJxA_2aB/fake_rolex_watches - fake rolexes

  • 17  |  June 5th, 2008 at 4:07 am by EOSN-Company

    У истоков нашей компании находилась команда специалистов, занятых в различных сегментах, которые, в любом случае, затрагивали сферу промышленного оборудования - это эксперты по строительству и разработке проектов, производственники и верхи управления, создатели и ширококвалифицированные монтажники. Расширение плотного сотрудничества между ними привело к умозаключению совместить силы в рамках одной фирмы , и 26 апреля 07 года была образов
    ана Компания «ЕвроОснащение».

    Корпорация является ведущим предприятием России по продаже промышленного оборудования , уверенно развивающиеся технологически-развитые сферы нашей компании позволяют реализовать самые нелегкие задачи наших клиентов по подбору, усовершенствованию, запуска и выпуска готовых решений!

    Качественные решения задач и профессиональное оборудование, поставляемое для их реализации, такие как
    мотопомпы ,
    компрессоры ,
    - это комплексный подход обеспечивает реализацию максимально эффективных решений, направленных на повышение независимости и эффективности бизнеса клиентов в кратчайшие сроки.

    Обширный опыт, общие идеи и желание реализовать творческий и профессиональный потенциал обеспечили стремительный рывок компании за относительно небольшое время, а принятая на себя ответственность за качество продукции и предоставляемых услуг помогла компании завоевать надежную репутацию.

    Задачи, стоящие сегодня перед нами, нельзя назвать лёгкими, но мы верим в их реализацию и в то, что наше предприятие расширяя спектр услуг, и ассортимент предлагаемого оборудованиям поможет Вам в осуществление своих целей.

    Мы учитываем растущие потребности клиента и опираемся на индивидуальный подход к каждому.

    Клиенты для нас - это не просто покупатели. Наши клиенты - это партнеры!

  • 18  |  July 1st, 2008 at 8:45 am by Assictal

    Purtroppo devo affrontare una partita importante e sono molto nervoso… avete qualche cosiglio da dare?proponetevi….sia sposo che testimoni e damigelle…. xD
    grzaie a tutti per le vostre “candidature”… ma ho scelto Michael….. x gli altri ci penso ancora un p??…. xD
    Tiziana, sar?? la mia fedele testimone e Migi il lanciatore di chicchi di riso…. xD
    Chat

  • 19  |  July 2nd, 2008 at 11:52 am by Gelmjearl

    aiuto??!!!!!?????????!!!!!!?- Di due gemelli identici almeo uno ?? malvagio.
    - Se dovete disinnescare una bomba, non preoccupatevi di quale filo dovrete tagliare. Sceglierete sempre quello giusto.
    - La maggior prate dei computer portatili ?? sufficientemente potnte per prendere il controllo dei sistemi di comunicazione di qualsiasi invasore alieno.
    - Non importa se siete soverchiati da un gran numero di avversari in un combattimento che preveda l’uso di arti marziali, i vostri nemici aspetteranno pazientemente, danzandovi gioiosamente intorno, che voi abbiate neutralizzato il loro predecessore prima di attaccarvi.
    - Quando spegnete la luce per andare a letto, ogni cosa nella vostra stanza continuera a esserte chiaramente visibile, solo leggermente colorata di blu.
    - Se siete bionda e procace, ?? possibile che diventiate un esperto di fama mondiale nella fissione nucleare a 22 anni.
    - I poliziotti onesti e seriamente dediti al loro lavoro vengono di norma uccisi tre giorni prima di andare in pensione.
    - Invece di sprecare pallottole i megalomani preferiscono cercare di uccidere i loro nemici usandoo complicati marchingegni che comprendono razzi,sistemi di pulegge,gas mortali,lasere squali mangia uomini che lasciano almneno 20 minuti di tempo per fuggire ai loro prigionieri.
    - Nel ccorso di un’indagine ?? necessario entrare almeno una volta in un club di striptease.
    - E’ facile per chiunque fare atterrare qualsiasi aeeoplano,basta che ci sia qualcuno nella torre di controllo che vi spiega come.
    - Una voltaq applicato sulle labrba il rossetto non se ne va neppure in caso di immersione subacquea.
    - La torre Eiffel ?? visibile da qualsiasi finestra di Parigi.
    - Se c’ ?? una grande vetrata in una stanza prima o poi qualcuno ci verr?? gettato attraverso.
    - Un uomo non mostrer?? alcun segno di dolore mentre viene ferito nel modo pi?? orribile ma urler?? quando una donna cercher?? di medicarlo.
    - Un detective riesce a risolvere brillantementer un caso solo quando ?? stato sospeso dal servizio

    ____________________________________________________________________________
    chat

  • 20  |  July 13th, 2008 at 10:20 pm by Marta19

    Siemka

    Ostanio wpadlam na fajne : YEE PL

    YEE PL

    Pozdrawiam
    Marta19

  • 21  |  July 19th, 2008 at 2:25 am by Progressive

    If you look at the progressive nature of this, the proof is in the truth!

  • 22  |  July 19th, 2008 at 10:22 am by fumBianyfum

    http://www.hairstylestop.com/wp-content/uploads/2008/07/lipstick0.jpg
    Lindsay Price is seen here in between takes on the set of Lipstick Jungle on location in New York City. Lindsay plays the role of an up and coming, albeit struggling, fashion designer in New York City, and she always seems to have style and wardrobe that is iconic to the struggling designer quirky yet trendy. She is playing up this quirkiness with a look that is very reminiscent of Carrie Bradshaw s flower year in Sex and the City and Lindsay has had her hair styles in a mess of curls and festooned with a bright flower. The curls in this look are achieved with small sized rollers, and then finished with a very narrow curling iron. You will want to ensure that you have a healthy amount of mousse or curling serum in your hair before you attempt this look. Keep your rollers in for at least 30 minutes, and remember to use your smallest sizes if you want curls as tight as Lindsay. When you take your rollers out, create a side part, and finger comb out your curls. Clip a barette or pretty flower to the side f
    or a fun and flirty summer look. If you need to neaten up your curls at all, do so with the narrow curling iron to freshen up your bouncy curls.
    Welcome to the Hairstyles Top. Here you will find the latest top hair style pictures, and advice for new hairstyles: sedu hairstyles, men’s hairstyles, short hairstyles and curly hairstyles, etc. Lots of celebrity haircuts.

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed

Calendar

September 2006
M T W T F S S
« Aug   Dec »
 123
45678910
11121314151617
18192021222324
252627282930  

Most Recent Posts

Feeds


Links

Subscribe

Social Bookmarks