Solved

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

Posted on 2004-09-08
17
448 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now