users@grizzly.java.net

Re: newbie help: read from console, send to browser

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Wed, 02 Jul 2008 10:49:32 -0400

Salut,

falcon wrote:
> I haven't done web related projects for many years so please excuse me if I
> missed something simple.
> How do I send messages to a website, straight from my Java application
> (perhaps using the Bayeux protocol)?

You can use an http library (like Apache Http Commons) to send http
requests to your remote application. You can also use a Socket and
create http messages using it. Or uses JMS.

>
> For example, say my Java program reads user input from the console in a
> loop. Every time the user types something and presses enter, it is sent to
> web browsers listening to the relevant 'channels.'
>
> My real goal is to push JMS topic messages to my web application!

Yes, this is doable :-)


>
> I have played around with grizzly-cometd-webserver-1.8.0.jar and
> grizzly-cometd-echo-1.8.0.war. I even tried loading my own servlet
> (actually a modified version of the one here:
> http://blogs.sun.com/swchan/entry/java_api_for_cometd) using the following
> format:
>
> java -jar grizzly-cometd-webserver-1.8.0.jar -p 8080 -a
> grizzly-cometd-echo-1.8.0.war TestServlet
>
> I put in a bunch of print statements in TestServlet, just to see how the
> code is executed, apparently my servlet wasn't even picked up.

Are you seeing exception on the console after launching your Servlet?
What is the exact name of your Servlet?

>
> In any case, any pointers or example code will be appreciated.

Can you share your Servlet code? How do you invoke your Servlet? Using a
browser?

Thanks

-- Jeanfrancois



>
> Thanks