Here's the thing, I want to create a chart and save it as PNG but doesn't work. This is the code:
Code: Select all
<%@ page import="org.jfree.chart.ChartFactory"%>
<%@ page import="org.jfree.chart.ChartUtilities"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="org.jfree.data.general.DefaultPieDataset"%>
<%@ page import="java.io.File"%>
<%// Create a simple pie chart
DefaultPieDataset pieDataset = new DefaultPieDataset();
pieDataset.setValue("Ubuntu", new Integer(75));
pieDataset.setValue("Xubuntu", new Integer(10));
pieDataset.setValue("Kubuntu", new Integer(10));
pieDataset.setValue("Others", new Integer(5));
JFreeChart chart = ChartFactory.createPieChart("Sistemas Operativos", pieDataset, true, true, false);
try {
ChartUtilities.saveChartAsJPEG(new File("PieChart.jpg"), chart, 500, 300);
} catch (Exception e) {
System.out.println("Error.");
}%>
<%
out.println("Hello");
out.println("Hello");
out.println("<script type=\"text/javascript\">alert(\"Hello\");</script>");
%>
And the prompt asking for "save file" never appears Neither the image automatically save it in the tmp directory or the one where the file is located (let's say /home/darwin/webapps/ROOT/test/).
Any ideas or help plz? I'm using CentOS 6... don't know what else do you need to know. Thank you!