Graphic without image jsp

3

Hello! I am trying to generate graph by jsp

I tried following this tutorial

But there is only one little square in the left corner of the page when I run File Torta.jsp

<%  
    try{
      DefaultPieDataset data = new DefaultPieDataset();    
      while(rs.next()){
          data.setValue(rs.getString("marca"), rs.getInt("TOTAL"));
      }

      JFreeChart grafico = ChartFactory.createPieChart("Cantidad Productos", data, true, true, true);

      response.setContentType("image/JPEG");
      OutputStream sa = response.getOutputStream();

      ChartUtilities.writeChartAsJPEG(sa, grafico, 600,600 );

    }
    catch(Exception ex){
    }
%>

File conexion.jsp

<%
     Class.forName("com.mysql.jdbc.Driver").newInstance();
     Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/producto","root","123");
     Statement cmd= cn.createStatement();
     String sql = "SELECT MARCA, SUM(CANTIDAD) AS TOTAL FROM   PRODUCTO_CANTIDAD GROUP BY MARCA";
     ResultSet rs = cmd.executeQuery(sql);
%>

Image of how the chart appears:

Thanks in advance.

    
asked by anonymous 18.10.2016 / 20:11

1 answer

0

Some possibilities:

  • How are you referring to this image on the page?
  • Have you tried to execute this query in the database to see if it returns data?
  • Tried to put an ex.printStackTrace () in the catch to see if there is a running error?
  • 18.10.2016 / 20:48