Marcus Dryice Koh
Marcus Dryice Koh

Reputation: 117

Unable to display 3D pie chart on JSP page

As the title says,I am unable to display the 3D pie chart on the JSP page,even after the image has been saved.I tried both absolute and relative paths,but it still does not work.Could anybody help to resolve this problem?

Here is the source code:
AnalyzeUserClient.jsp(Java codes)

DefaultPieDataset pieDataset = new DefaultPieDataset(); 
BufferedReader bReader =new BufferedReader(new FileReader("C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/user.txt"));
String s;
while ((s=bReader.readLine())!=null){
   String datavalue [] = s.split("\t");
   String category = datavalue[0];
   String value = datavalue [1];
   pieDataset.setValue(category, Double.parseDouble(value));
}
bReader.close();

JFreeChart chart = ChartFactory.createPieChart3D(
            "Percentage of Each Category for User", pieDataset, true, true, true);

PiePlot3D p = (PiePlot3D) chart.getPlot();
p.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {2}"));
p.setForegroundAlpha(0.5f);
p.setBackgroundAlpha(0.2f);

chart.setBackgroundPaint(Color.white);
chart.setAntiAlias(true);
chart.setBorderVisible(false);
chart.setTextAntiAlias(true);

try {
    ChartUtilities.saveChartAsPNG(new File("C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/AnalyzeUser.png"), chart, 800, 600);
    } catch (IOException e) {
        e.printStackTrace();
        System.err.println("Problem occurred creating chart.");
    } 

AnalyzeUserClient.jsp(HTML codes)

<img src="C:/Users/L31207/Desktop/eclipse-jee-juno-win32/eclipse/AnalyzeUser.png" height="500px" width="500px" usemap="#chart">

Upvotes: 0

Views: 629

Answers (1)

Matt Ball
Matt Ball

Reputation: 359826

The <img src="..."/> needs to reference a resource that the client – a browser not running on the same machine as your server – can access. This is not the case with an href pointing to a file on the C: drive. You need to provide HTTP access to the image stored in that file.

Upvotes: 1

Related Questions