Reputation: 1461
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).
Upvotes: 2
Views: 2378
Reputation: 1109532
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.
Upvotes: 7