Solved

How do I deal with temporary image files (like charts)?

Posted on 2004-09-08
17
453 Views
Last Modified: 2008-02-01
If I'm going to produce a Web Page using JSP with images (like charts), then what are the best ways to deal with this?

I mean, if it is just plain HTML it is just streamed to the browser. But with images I have to save them somewhere. But when is it safe to erase them? What is the best way to erase them? I mean what would trigger the erase code? Is there way to run some "sweeper" code once in a while that checks if it is ok to erase these files and, if so, does it?
0
Comment
Question by:ycomp
  • 10
  • 6
17 Comments
 
LVL 19

Expert Comment

by:ramazanyich
ID: 12008704
If you use some Java packages for image creation (www.jfree.org and cewolf.sourceforge.net) you don't have to store temporary image files.
Image will be generated on the fly by servlet for example and you just need point to servlet (with some parameters) as src attribute value of img element.
Example:
<img src="/cewolf?param=value&param2=value2"/>
0
 

Author Comment

by:ycomp
ID: 12008745
but if my charts are complicated and have many data series, etc. how do I do this easily? I would have to pass a very very long url and write code to parse it all, right?

I'm thinking to use JCharts
0
 

Author Comment

by:ycomp
ID: 12008777
I mean, I would have to write code to encode all chart parameters to a long url (what is the max length of URLs?) and then decode it all to set the attributes.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:ycomp
ID: 12008983
I've been thinking... I guess I can live with this approach provided that I can pass all the data via the URL. Is this feasible? Or is the query string of a URL limited to a certain length?
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12009002
You should submit by form and use post method that allow you unlimit length of data.

<form name="form1" method="post" action="servletToGenerateChart">
  <input type="hidden" name="data" value="as long as you want">
</form>
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12009015
It depends on web server you use. most of web server do not allow to submit length of url more than 255 byte
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12009030
and here is javascript to submit form

<script language="javascript">
  function submitData() {
    document.form1.submit();
  }
</script>

:) just assume you don't know javascript to submit form. If you know, ignore this.
0
 

Author Comment

by:ycomp
ID: 12009039
hi, thanks... I'm a bit confused. How does my form post get turned into an <IMG> tag?
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12009068
Are you using cewolf?
0
 

Author Comment

by:ycomp
ID: 12009082
No, I want to use JCharts
0
 

Author Comment

by:ycomp
ID: 12009113
I want to have a JSP file that produces my HTML code. Within that I will have some embedded charts. I want these charts to be based on data that is somehow embedded in the HTML. The HTML should call another JSP to render them.
0
 

Author Comment

by:ycomp
ID: 12009133
That is my new approach to solving my problem (provided it is possible). The 256 char limit in the GET string would be a problem, so I'm trying to find another way.

My old idea was to have the JSP that generates the HTML to also generate the chart images but then they would have to be saved somewhere temporarily (and thus removed eventually somehow, which is a big mess)
0
 
LVL 11

Accepted Solution

by:
sompol_kiatkamolchai earned 500 total points
ID: 12009220
Yes. it needs temporarily file of generated image. After I review JCharts, I think it's a generic tool for generated image by java.

I recommend you to use cewolf. It's quite easier one. since it's taglib
here is an example

<cewolf:chart     id="XYChart"    type="xy"    title="XYChart">
  <cewolf:gradient>        
      <cewolf:point x="0" y="0" color="#FFFFFF"/>        
      <cewolf:point x="0" y="300" color="#C8C8C8"/>    
  </cewolf:gradient>    
  <cewolf:data>        
    <cewolf:producer id="xyData"/>    
  </cewolf:data>
</cewolf:chart>
<cewolf:img chartid="XYChart" renderer="cewolf" width="400" height="300"/>

more details, http://cewolf.sourceforge.net
0
 

Author Comment

by:ycomp
ID: 12009306
hmm, so it looks likes I'm back to my original question. Thanks for the help though.

Anyone know if there is some generic java library that is made to handle temporary files with a Servlet / JSP image generating environment in mind?
0
 

Author Comment

by:ycomp
ID: 12009532
although my question was not really answered, I learned a lot and have rethought my approach. So I'm closing this topic because I don't think I need to generate temp files anymore.
0
 

Author Comment

by:ycomp
ID: 12009541
sorry I meant "although my INITIAL question was not really answered". thanks for the help.
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 12016172
thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maven webservice projet error 6 80
Adjusting width and height of dropdown produced using select n option HTML tags 4 95
Java Exception example issues 11 84
maven set up 2 191
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
We have put together a white paper that aims to explain how MSPs can both improve their offering and ease the pain of after-hours service by: -Suggesting changes to workflow -Indicating how to rework policy to suit your team -Providing ConnectW…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

697 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question