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.