This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using a applet to paint a Bar Chart. The applet will take the input from a text file and paint the chart. Each time when a different input is given from front end (JSP) the text file gets updated with new data and the applet draws the chart according to the text file data.
When I give a input from front end for the first time the Applet paints the chart correctly accordng to the data in the text file but when I change the input the applet shows the same (previous) chart(from cache) and it does not paint the new chart with the new value.
I tried clearing the cache from java console and also tried adding image.flush() in applets stop method.
Nothing works. It will be great if anyone help me on this.
Thanks in advance Ganesh
SJCP (95%), SCWCD (75%), SCDJWS (Planning to take....)
Just to make sure I understand the architecture: There is an HTML form into which the user enters some data. This is then submitted to the server, where the data is written to a file. Then you redirect to the applet page, and then the applet retrieves the file from the server and paints the chart. OK?
Is the file actually updated? Does the applet retrieve the file successfully, and gets the new values?
This problem may caused for many reasons. First is as the previous answer said make sure if the updated values coming correctly from the server.you can print the file content to java console by System.out. or Swing's JOptionPane in orrder to be sure whether its correctly coming or not.
Second is if its coming correctly the there must be a failure with repainting. for example if you are using double buffering maybe you forgot to flush the last graphic?
ummm I dont know any other?i must see to say you more and know more about the structure..
Joined: Feb 09, 2006
Thanks for ur reply.
Ulf Dittmer, u got the architecture correct. The file has the updated values. but the applet is just looking at the cache and displaying the previous image.
sinasi susam , I disabled caching and also tried flushing the image.
I suspect it is refering classloader cache anyways to clean up this cache programatically or disable this cache ??
I can send u the applet class if u give ur mail id.
Joined: Mar 22, 2005
How do you read the file? Is it on a shared drive so the applet can get at it? Or is it in the applet directory in the web server, and you're using the classloader and an inputstream?
Are you using JFreeChart by any chance? Its CategoryDataset and its subclasses cache dataset information if the parameters are unchanged. The solution to that would be to add a dummy parameter that changes every time.
Joined: Feb 09, 2006
Hi, Thanks for the reply. Find below the details u asked
Inside Appllet class **************************
addImage = getParameter("chartdata"); // gives the txt file name if(addImage != "" && addImage != null) addElement(addImage);