views:

225

answers:

2

Hi,

We are trying to create a reverse ajax in our project.

I've checked on the net and didn't find something concrete. I was unable to run any of the tutorials provided successfully.

My object is: to provide on-screen alerts (like a pop-up) when ever there is an even pushed from the server (it could be high cpu usage/ram, anything).

Any pointers would be of great help.

Panther24

+4  A: 

The HTTP protocol (fortunately, after all) doesn't support PUSH, so it stops there.

Best what you can do is to let the client fire ajax poll requests at timed intervals I can recommend jQuery.ajax() in combination with setInterval() for this.

Alternatively (and with a bit more effort) you could make use of Comet technique (which simulates the fictive HTTP PUSH less or more). Check the appserver specific documentation/wiki using this keyword for details. Here's a Tomcat targeted example: http://wiki.apache.org/tomcat/WhatIsComet

Edit: as requested, here's a Tomcat+Comet tutorial to get started: http://www.ibm.com/developerworks/web/library/wa-cometjava/#N100CC Hope this helps.

BalusC
I understand that BalusC, I've tried Comet. All I need is a working example to i can kick-start :)
Panther24
I googled "tomcat comet tutorial", I found a good link, I edited my answer.
BalusC
I've tried that too, but with little success and its more aligned towards GWT!!
Panther24
I see. I've replaced the link with another one I found.
BalusC
BalusC, the IBM link was the 1st one i tried ever and the issues with that have been posted all over the net without a solution :(
Panther24
Interesting. Maybe if I have time I will try this. I must admit, I know about this technique for years, but it has never encouraged/interested me that much that I'd actually play around with it. HTTP simply isn't the right tool for this.
BalusC
Never mind, i tried to use streamhub and it worked fine.Thanks for your help BalusC!!
Panther24
+1  A: 

Here is a valuable resource

Tinku
Currently I'm trying it with DWR :)
Panther24