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…
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 \
.http-listener-1.property.cometSupport=true
or
$ 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="0.0.0.0"
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"/>
</http-listener>
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″;
urchinTracker();
