Reverse Ajax + JSP-Servlet

2.3k Views Asked by At

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

2

There are 2 best solutions below

7
BalusC On

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.

1
Tinku On

Here is a valuable resource