Home > Uncategorized > Comet support in GlassFish

Comet support in GlassFish

Want to learn how to write and deploy a web application based on GlassFish’s Comet? Four little steps to surf the Comet’s tail…

GlassFish AppServer - Get it Now

Download GlassFish

Download the latest v2 ur1 version here. Read then installation guide here. From now I will use ${glassfish.home} to reference your installation directory.

Enable Comet support in GlassFish

By default, Comet support in not enabled in GlassFish. Why? Because two years ago it was hard for me to convince my co-workers about the new Comet revolution. But things has changed now, and you can even spend days reading on Comet. To enable Comet in GlassFish, just do:

${glassfish.home}/bin/asadmin set server.http-service.http-listener \


$ vi ${glassfish.home}/domains/domain1/config/domain.xml 
add the following bold line under the http-listener port 8080
<http-listener acceptor-threads="1" address="" 
           blocking-enabled="false" default-virtual-server="server"
           enabled="true" family="inet" id="http-listener-1" port="8080"
           security-enabled="false" server-name="" xpowered-by="true">
                <property name="cometSupport" value="true"/>

Comet in Action

You are now ready to see what Comet does. Just deploy one of the following war file (save the war under ${glasfish.home}/domains/domain/autodeploy):

  • JMaki little game: When you type a word, the word will be displayed using Flickr photos and shared amongst all browser. As soon as you move the words, all browsers will be updated with the word’s new position. You can even play chess by adding letters
  • Simple Chat application: A simple Chat application based on Comet
  • WebMc : WebMC is an ICEfaces demo application that lets you host a slide presentation over the internet.
  • DWR examples: DWR‘s Reverse Ajax demo running on top of GlassFish!

Start two browsers, hits the application url (ex: http://localhost:8080/jmaki-comet/) and see real time updates executed from one browser on the second one!

Wow, I want to write tons of Comet applications, where do I start

Take a look at the iFrame example or the javascript Prototype example as a start, and browse more documentation here. Ask questions using the users@glassfish.dev.java.net!

_uacct = “UA-3111670-1”;


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: