I am developing an applet which displays the current weather. The applet gets the data from a database through a servlet. The servlet sends a data to the applet only when a request is invoked by the applet. Is there a way that the servlet sends data to the applet whenever there is a change in weather without the applet sending request.
It's not possible in general for a server to make contact with an applet. But it's not much overhead for the applet to send a short request every few minutes or so to check if something has changed (or maybe even longer timeframes, depending on how often the server data is updated).
But is an applet really the right tool for a job like this? It would rely on a web page being continuously open.
I am choosing an applet for this application becuase 1)it is web based 2)I need the applet to plot a waveform(chart) accordingly.
Pooling for new data from time to time would be good for you application.
There might be many ready to use AJAX components might be available for this purpose.
One downside to this is that it requires another port to be open. This can be a hassle for a lot of companies with strict firewall policies.
If I were doing this, I would probably follow Ulf's advice and have the applet poll the server every n seconds.
Joined: Nov 29, 2005
I found the following link ,
URL-1 , This might not be using ajax , but if we can make out a graph in the client side then we should be able to use AJAX to fetch changing data from server time to time.
There are many third parties (http://www.activewidgets.com/) which sell ready to use AJAX based GUI components.There might be something like this for making graphs. Well I have never used graphs , but used data grids though.
Ben Souther:If he's already got an applet on the page, there is no need for AJAX.
Thats true.I just wanted to let him know that there might exists ready to use AJAX based component for his graph requirement.
[ July 06, 2007: Message edited by: Rahul Bhattacharjee ]
Joined: Jul 05, 2007
thank you all for your suggestions.
Joined: Jul 05, 2007
hello guys I am done with the database access. Now I am now developing a chat using applets and servlets. I am having a difficulty in sending the a user name to to the applet. the first html page accepts user name and this will be sent to a servlet which will then redirect to the applet page. now my problem is in sending the user name to the applet. Note that my applet's get and post methods are used for requesting new message and sending a message.
Joined: Mar 22, 2005
Can you create the applet tag dynamically, and add a "<param name="username" value="...">" to it?