Clarification regarding ServletUtilities while creating JFre

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
senthil
Posts: 12
Joined: Thu Apr 17, 2008 8:48 am

Clarification regarding ServletUtilities while creating JFre

Post by senthil » Sun May 11, 2008 4:30 pm

I am using Servletutilities class while saving the Jfree Chart in a temporary path
it stores the JFree Chart in name of JFreeChart-03266.png
if i am just trying to save another time

it goes to save like 'JFreeChart-03268.png'

it increases by 2 .....

is there any possibilty top increase by 1 ..

my application will be used my many user ,...


so if it reaches any critical value , may cause problem in saving file


can you give me about any idea about these above problems


file name which i am saving can be created my our own defined name ...


is it possible ?

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Sun May 11, 2008 7:12 pm

The ServletUtilities class uses "File.createTempFile" to create the file. Therefore it is safe to be used in a multi-user application. The +2 increase you see in each file is just a side effect on how the JDK creates the file. However, the JDK guarantees that the new temporary file is created in a safe and sane manor.

@see java.io.File#createTempFile(String, String, File)

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Sun May 11, 2008 7:15 pm

More on that: The files that are created are registered to be deleted as soon as the session of the user expires. So assuming that your users don't lurk on the server forever, the files that are generated should be deleted as well.

And if your server hits the critical level of concurrent users all generating charts at the same time, then the file system will be the least of your problems (assuming that you have a gigabyte or two to spare). The CPU contention will kill your server before the temp-dir can become a problem :D

senthil
Posts: 12
Joined: Thu Apr 17, 2008 8:48 am

Post by senthil » Mon May 12, 2008 12:54 pm

I really appreciate your immediate reply.


I think there is a small misunderstanding.


Iam using jfreechart 1.0.1 version for my application.


I am using saveChartAsPNG(JFreeChart chart, int width, int height, HttpSession session) method to display the chart to my end user. Also it is working fine as i expected.



I am using the default file name provided by Jfreechart 'JFreeChart-03268.png'

In this default file name 'JFreeChart-03268.png' the sequence number generated by Jfreechart is 03268



Actually my questions are:

1. How is this sequence number generated by Jfreechart?

2. Is there any possibility for me to provide this sequence number explicitly?

3. As it already started with 4 digit number, i would like to know what is the starting value of this sequence number?

4. As there are huge numbers of users for my application, I would like to know what would be the maximum number till this sequence number can grow or what is the upper limit of this sequence number?

5. Will it reset automatically after it reaches the upper limit or we need to set any parameter so that once it reaches the upper limit it should start again from 1?

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 » Mon May 12, 2008 4:51 pm

senthil wrote:1. How is this sequence number generated by Jfreechart?
As Thomas (Taqua) said, the sequence number is generated by the java.io.File.createTempFile() method provided by the JRE. JFreeChart doesn't generate it.
David Gilbert
JFreeChart Project Leader

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

Locked