2

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).

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Vivek
  • 1,451
  • 8
  • 42
  • 74

2 Answers2

7

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
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I understand that BalusC, I've tried Comet. All I need is a working example to i can kick-start :) – Vivek Nov 20 '09 at 14:56
  • I googled "tomcat comet tutorial", I found a good link, I edited my answer. – BalusC Nov 20 '09 at 15:01
  • I've tried that too, but with little success and its more aligned towards GWT!! – Vivek Nov 20 '09 at 16:12
  • I see. I've replaced the link with another one I found. – BalusC Nov 20 '09 at 18:24
  • 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 :( – Vivek Nov 21 '09 at 04:07
  • 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 Nov 21 '09 at 04:30
  • Never mind, i tried to use streamhub and it worked fine. Thanks for your help BalusC!! – Vivek Nov 27 '09 at 08:10
1

Here is a valuable resource

Tinku
  • 1,592
  • 1
  • 15
  • 27