ChartUtilities.writeChartAsJPEG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Frenk

ChartUtilities.writeChartAsJPEG

Post by Frenk » Tue Aug 27, 2002 1:59 pm

Hello all,
I use a Servlet joined with JFreeChart. Here I use the writeChartAsJPEG-method of the class ChartUtitlities of the package com.jrefinery.chart. All works fine. This method encode a JPG-File with my OutputStream that it get over parameter. At the moment the client get the chart and it will be displayed by the browser, fine!. But I want that the client (browser) starts a "Save As..." window, where it is possible to save the chart in the own directory (and I don't want to use the right mouseclick). Is there a possibility to do that.
I tried to change the response.setContentType to "application/octet-stream", but I seemed not to work. In the servlet I tried to write a method like this:

public BufferedInputStream getPicture(JFreeChart chart, int width, int height) {
InputStream is = null;
BufferedInputStream bis = null;

try {
BufferedImage image = chart.createBufferedImage(width, height);
is = new InputStream(image);
bis = new BufferedInputStream(is);
}

catch (Exception e) {e.printStackTrace();}
return bis;
}

Can anybody help me !

Locked