I have an app that is essentially a monitor of system status. The status is stored in a database table and can be updated by several different apps. My web app needs to display this status information and automatically update itself should any status change. I am interested in opinions as to how to do this in a J2EE implementation.
an applet would be better in that you could implement a push mecanism where you dont have to constantly poll the server, cutting down on network traffic and server load.
If you are going to get the page to refresh, I recomment you play around with the caching, so at least it should only download the page headers every minute, and the whole page only when the status chnges. To do this, keep a variable in memory that contains the time. When ever the status is changed, update this varialbe with the new time. Every time you request the page you want, set teh last-modified tag to the variable from memory. Also set the cache tags so that the page will be cached by the browser. That way the browser will get the latest of the page, get the headers every so often (you would probably set the refresh for something like 30 or 60 seconds) but as long as the status stays the same (and your variable with the last modified time of the status) the browser will get the HTML for the page from its cache, and not download it again from the server.
I strongly disagree -- push mechanisms are quite difficult to get right, and many firewalls will not allow a server to initiate an outgoing connection -- not to mention the fact that the only way to allow an initiated connection from an applet is to sign the applet -- defeating the purpose of the applet sandbox.
I agree with Kyle that the push is tricky and might complicate maintenance down the road. I was hoping to get some ideas from everyone on how to do this other than with a page refresh but I am not seeing much. The only reason I dislike the page refresh is that in order to reduce the network traffic, I need to make the auto-refresh at least a minute, if not more. But this delay makes it less realtime monitor than a near-realtime monitor. Perhaps someone knows of some COTS that has solved this problem?
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop