filename returned by ServletUtilities.saveChartAsJPEG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Lanto

filename returned by ServletUtilities.saveChartAsJPEG

Post by Lanto » Thu Jan 30, 2003 9:23 am

Hi all,

I'm using JFreeChart inside a servlet. For my need, I have to create a temporary JPEG file and put its pathname in a XML file for a global PDF rendering.
The problem is that the method ServletUtilities.saveChartAsJPEG doesn't return the absolute (or relative) path, but only the filename. When the PDF renderer tries to read the JPEG file, it gets a FileNotFoundException...

Is there any solution to get the path of the file created by saveChartAsJPEG ?

Thanks,

Lanto

Richard Atkinson

Re: filename returned by ServletUtilities.saveChartAsJPEG

Post by Richard Atkinson » Thu Jan 30, 2003 9:57 am

The ServletUtilities class saves the file in the temp directory so you can use the System Property "java.io.tmpdir" to determine exactly where it is. Take a look at the source of the DisplayChart servlet to see an example of using a temp file. The critical line is

File file = new File(System.getProperty("java.io.tmpdir"), filename);

Hope this helps.

Regards,
Richard...

Lanto

Re: filename returned by ServletUtilities.saveChartAsJPEG

Post by Lanto » Thu Jan 30, 2003 3:45 pm

Hi Richard,

Thanks for your answer.

Lanto

Locked