[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-09-08
17
Medium Priority
?
456 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

WooCommerce is becoming the most powerful e-commerce plugin for Wordpress. And why not. The platform comprises of numerous core plugins that may come in handy, powerful options to make your website development task much easier.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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