Deleting temporary images

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Steve
Posts: 53
Joined: Mon Dec 22, 2003 8:29 pm

Deleting temporary images

Post by Steve » Tue May 10, 2005 3:32 pm

How would I go about deleting the images jfreechart creates in tomcat's temp directory? I assumed they'd be cleaned out by Tomcat, but this is not the case.
I saw some mentions to a ChartDeleter class, but I am unsure how to use it, or if it's suppose to be used to do this.

Thanks.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue May 10, 2005 7:22 pm

My understanding of the ServletUtilities class is that it looks for an existing ChartDeleter in the current session, automatically add a new ChartDeleter if none is found, registers the temporary file with the ChartDeleter, and when the session expires the ChartDeleter removes all temporary files that have been registered with it. But I didn't write these classes and don't use them so I could be wrong.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Wed May 11, 2005 7:44 am

In the 1.0pre2 version there is also another possibility. Setting the session to null

Code: Select all

filename = ServletUtilities.saveChartAsPNG(chart, 950, 600, cri, null);
will cause that the DisplayChart servlet will delete the file after the first request.

Steve
Posts: 53
Joined: Mon Dec 22, 2003 8:29 pm

Post by Steve » Wed May 11, 2005 3:49 pm

Ok, thanks guys.

I'll try setting the session null.

Dave, do you know if the images created (and stored in tomcat's temp directory) are suppose to be deleted at some point in time?
Or is it default behavior to stay there permanently?

Thanks!

Steve
Posts: 53
Joined: Mon Dec 22, 2003 8:29 pm

Post by Steve » Thu Jul 14, 2005 8:37 pm

Anymore info on this?

Locked