How can I add automatic refreshing to an existing webpage
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, July 3, 2006 01:21 PM

Hello all. I'm very new to AJAX. I've been reading up on it and it seems like the answer to a problem I've been having with a project of mine.

Long story short, is it possible for me to add automatic refreshing (without reloading the page) to my project without doing major surgery? The page is a jsp with some data retrieved from the server on it, I would like to be able to have it refresh the data on the page without resetting a bean object also on said page (I have reasons for not wanting to use a session scope bean).

Any help at all would be appreciated!

Re: How can I add automatic refreshing to an existing webpage

Posted By:   Ajay_Prabhakaran  
Posted On:   Tuesday, July 11, 2006 03:48 AM

William,
I am not an expert in AJAX, but created a few pages and worked on it. From the description of your problem, you should be easily be able to put in some Javascript functions to use XMLHttpRequest and communicate with the server and render the response in Javascript. This should remove reloading of the page and ensure refresh happens automatically and retreives data from the server. You should be able to include this wherever you are posting data to the server from the client application (either HTML get/post).

Re: How can I add automatic refreshing to an existing webpage

Posted By:   Ronnie_Kilsbo  
Posted On:   Tuesday, July 4, 2006 02:12 AM

Well yes, it is possible.



Assuming you know how to get the data (doesn't matter if it is a session scope or not), there isn't really a problem to do so.



I do not know what you mean by automatic refreshing but I assume that it should be timer-based.



What you do is that you request the data from another page that returns an XML, you then parse it with javascript and put the data in the page using the HTML DOM and the Java API for it. This means that your page does not reload, another page is reloaded and your javascript in your jsp-page distributes the data.



I do not know your AJAX experience so I will put you at start with this link:



http://developer.mozilla.org/en/docs/AJAX:Getting_Started

So what you need is to use the setTimeout() function in javascript to trigger the fetch of the information from your XML-resulting page with the data.

About | Sitemap | Contact