From: Nathaniel G. A. <nat...@ya...> - 2003-08-01 12:37:28
|
Outputting charts from JSP's is not a good practice. The problem you are seeing is there is some whitespace in your jsp which is getting written to the ServletOutputStream; so when you try to write binary data (ie your chart) the response has already been written to. To get around this, you will have to eliminate all empty spaces and lines between your <% and %>, and make sure there are no empty lines or spaces at the beginning and end of the file too. --- Malleswara Reddy B <bnm...@ya...> wrote: > the following is the code I have written > > <%@ page > import="java.awt.*,java.io.*,org.jCharts.*,org.jCharts.nonAxisChart.PieChart2D,org.jCharts.chartData.*,org.jCharts.properties.*,org.jCharts.types.ChartType,org.jCharts.axisChart.*,org.jCharts.test.TestDataGenerator,org.jCharts.encoders.JPEGEncoder13,org.jCharts.properties.util.ChartFont, > > org.jCharts.encoders.*"%> > > > > <%! > > PieChart2DProperties properties= new PieChart2DProperties(); > > LegendProperties legendProperties=new LegendProperties(); > > ChartProperties chartProperties = new ChartProperties(); > > int width = 550; > > int height = 350; > > > > > > legendProperties.setNumColumns( 2 ); > > legendProperties.setPlacement( LegendProperties.LEFT ); > > chartProperties > > try > > { > > PieChart2D pieChart2D = new PieChart2D( getData(), legendProperties, this.chartProperties, > width, height ); > > ServletEncoderHelper.encodeJPEG13( pieChart2D, 1.0f, response ); > > } > > catch( Throwable throwable ) > > { > > //HACK do your error handling here... > > throwable.printStackTrace(); > > } > > > > %> > > <%! > > private PieChartDataSet getData() throws ChartDataException > > { > > double[] data = new double[]{40, 15, 35, 65, 59}; > > Paint[] paints = new Paint[]{Color.blue, Color.red, Color.green, Color.yellow, Color.white}; > > String[] labels = {"Maruti", "Opel", "santro", "indica", "premier"}; > > return new PieChartDataSet( "Cars That Own!", data, labels, paints, this.properties ); > > } > > %> > > > > > Vikram Rajan <Vi...@PL...> wrote: > Can you give us some code sample to understand the problem better? This normally happens when > you try to use the <jsp:forward> or <jsp:include> tags after sending some information to the > client. > > Vikram > -----Original Message----- > From: Malleswara Reddy B [mailto:bnm...@ya...] > Sent: Friday, August 01, 2003 9:40 AM > To: jch...@li... > Subject: [jCharts-users] problem in pie2dchart > > > I need to generate pie2d chart for a dynamic data .the problems now I am facing is > > 1)if I put the code in jsp though chart is generated fine. its givving exception saying > "response already started" .if I generate chart with a servlet I have no problems. > > any help to solve this is appreciated > > thanks > mallesh > > > > > B.NagamalleswaraReddy > Member-Technical > ADPWilco(India) Pvt Ltd > > --------------------------------- > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software > > > B.NagamalleswaraReddy > Member-Technical > ADPWilco(India) Pvt Ltd > > --------------------------------- > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site design software ===== http://nathaniel-auvil.blog-city.com/ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |