• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Save Picture to Dynamic Web Project Filesystem

 
Philipp Otto
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there,

I want to export a chart, generated by JCharts, as a PNG- File to the file system of my web project, but can´t find the solution. I want to use a relative path and already tried almost every combination of paths. Here´s one of my tries:



The code is executed in a servlet in "Projectname/Java Ressources/src/servlets/File.java"

Which path do I have to use to save the Picture into my folder:

"ProjectName/WebContent/diagrams/"

Thanks for your help!

Philipp
 
Jagdish Hatagale
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use dots (..) in path like
FileOutputStream fout = new FileOutputStream("../diagrams/Test.png");

try out
Regards
jagdish hatagale
 
Philipp Otto
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot.

I found a better solution to display the chart in the JSP without saving it.
With ...
ServletEncoderHelper.encodeJPEG13( axisChart, 1.0f, response );
I can directly put the Chart into the servlet response and then display it with a simple <img> tag within the JSP. That´s even better! :-)

Philipp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic