This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JSP and the fly likes Save Picture to Dynamic Web Project Filesystem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Save Picture to Dynamic Web Project Filesystem" Watch "Save Picture to Dynamic Web Project Filesystem" New topic
Author

Save Picture to Dynamic Web Project Filesystem

Philipp Otto
Greenhorn

Joined: May 04, 2012
Posts: 4
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

Joined: Apr 07, 2010
Posts: 33
use dots (..) in path like
FileOutputStream fout = new FileOutputStream("../diagrams/Test.png");

try out
Regards
jagdish hatagale
Philipp Otto
Greenhorn

Joined: May 04, 2012
Posts: 4
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Save Picture to Dynamic Web Project Filesystem