hi everybody,
I met problems on generating chart by using jchart and jsp. the environment is with jCharts-0.7.0, j2sdk1.4.2_01, jbuilder development platform. there are the errors and code. The following are the errors:
ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: getOutputStream() has already been called for this response
ERROR [Engine] ----- Root Cause -----
java.lang.IllegalStateException: getOutputStream() has already been called for this response
The following is the code:
<%@ page import="java.awt.*,org.jCharts.*,org.jCharts.chartData.*,org.jCharts.properties.*,org.jCharts.types.ChartType,org.jCharts.axisChart.*,org.jCharts.test.TestDataGenerator,org.jCharts.encoders.*,org.jCharts.properties.util.ChartFont"%>
<%
try
{
String[] xAxisLabels= { "2001", "2002", "2003", "2004", "2005", "2006", "2007" };
String xAxisTitle= "Models";
String yAxisTitle= "Unit Sold";
String title= "Product Sold";
DataSeries dataSeries = new DataSeries( xAxisLabels, xAxisTitle, yAxisTitle, title );
double[][] data= new double[][]{ { 300, 10, 200, 70, 140, 20, 10 } };
String[] legendLabels= { "quantity" };
Paint[] paints= new Paint[]{ Color.cyan.brighter() };
BarChartProperties barChartProperties= new BarChartProperties();
AxisChartDataSet axisChartDataSet= new AxisChartDataSet( data, legendLabels, paints, ChartType.BAR, barChartProperties );
dataSeries.addIAxisPlotDataSet( axisChartDataSet );
ChartProperties chartProperties= new ChartProperties();
//---to make this plot horizontally, pass true to the AxisProperties Constructor
//AxisProperties axisProperties= new AxisProperties( true );
AxisProperties axisProperties= new AxisProperties();
LegendProperties legendProperties= new LegendProperties();
//AxisChart axisChart= new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, 550, 360 );
Chart chart=(Chart) new AxisChart( dataSeries, chartProperties, axisProperties, legendProperties, 550, 360 );
HttpServletReponse response=new HttpServletResponse();
ServletEncoderHelper.encodeJPEG13(chart, 1.0f, response);
//JPEGEncoder13.encode( chart, 1.0f, response );
} catch(Exception e)
{
System.out.println("this is the exception");
System.out.println(e);
}
%>
<html>
.....
</html>
Based on the above code, how to solve it if I need use jsp to program.
Urgent!! Please tell what happens and how to solve it!!
best regards,
benjamin
[ March 09, 2004: Message edited by: Benjamin Ho ]
[ March 09, 2004: Message edited by: Benjamin Ho ]
[ March 09, 2004: Message edited by: Bear Bibeault ]