Click to See Complete Forum and Search --> : problem with displaying updated XML file


TecH_BoY
10-13-2004, 05:41 AM
Hi pals,

I really need some help here. I am currently creating a Flash generated chart which reads data from a XML file. The data of the XML file can be dynamically changed via a HTML page. This is done using java servlet. So the overall work flow here is.

HTML(jsp) -> Java Servlet -> XML <- Flash

I hope this explains the entire workflow.

Now the problem is, the data updated in XML file doesnt make any changes to the flash chart. I am sure the problem isnt from the flash code, because the chart is updated automatically once i try refreshing the XML page manually via the browser(i open the XML file in browser and hit refresh, pop.... the view of the Flash Chart changes). I doubt the problem is in the Java Servelt code, or the HTML cache. Is there any java code to refresh the updated XML?

Here is my code for the Java Servet:


{
String data[] =request.getParameterValues("data_");
String valu[] =request.getParameterValues("values_");

try
{
Document document = new Document();

PrintWriter out = new PrintWriter( new FileOutputStream("copy_file.xml"));

Element root = document.setRoot("chart"); //XML manipulation
//using some package

for(int k = 0; k < data.length; k++)
{

Element h = root.addElement("chartItem");
h.setAttribute("ChartLabel" , data[k] );
h.setAttribute("ChartValue" , valu[k] );

}


System.out.print(document);
out.print(document);
out.flush();
out.close();

}
catch( Exception exception )
{
System.out.println( "exception: " + exception );
}
}

Note : the data in XML file is changing, but not the view. :confused:

Khalid Ali
10-13-2004, 11:36 AM
HTML is stateless,therefor, it has no idea that xml has been updated.
You may have multiple options to resort to.
1. use some code in the web page that will refresh/reload the page
e.g meta tag refresh or JavaScript force refresh after a prticular time.
2. Use an applet that will monitor server side changes and then reload the currently loaded html page(?)....

TecH_BoY
10-13-2004, 09:18 PM
Yo pal, thanx for the help. But it didnt work. I even try refreshing my HTML page manualy by clicking the refresh button, there is no diff.

Browser A (Flash Chart)
Browser B (XML file)

The A's view is only updated when i refresh B.
Or when i close A and reopen it.

Extra Info :
-How does the Flash Chart works? It loads the XML file
fetch the Data needed and unload it. So the flash is not
holding the XML file from being updated instantly.

-How does the Java Servlet manipulate the XML file? The
Java Servlet opens the XML file and simply write the new
data into it and closes it.
(I'm not really sure whether it does, i am using .close() code to do it)

Pls help me pal....

ray326
10-14-2004, 12:09 AM
Sure sounds like the Flash applet is caching the XML file and never rereading it.

TecH_BoY
10-18-2004, 03:24 AM
Come on guys,

I am still waiting for a really usefull post here. I know you guys can solve it :D