Hello fellows!
I have question.
Iam doing some project to my school and I have small problem.
I have chart (iam using jfreechart) in Chart.java file and after user is loading to his profe he should be able to push button and chart wit his statistics should appear. My problem is that I cant form proper onClick function. or mayby window.parent.location.href is wrong used?
<%@ page contentType="text/html; charset=iso-8859-1" language="java"%>
<html>
<head>
<script src="../WEB-INF/lib/amcharts.js" type="text/javascript"></script>
<title>Successfully Login by JSP</title>
</head>
<body>
<input type=button onClick="window.parent.location.href = 'src/java/demo/Chart.java' " value='Chart'>
</body>
</html>
That is my web jsp web, just one button calling java chart..
And here is my java chart class, calling data from database (this class works fine when iam Runing it separately
package demo;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.jdbc.JDBCCategoryDataset;
import org.jfree.ui.*;
public class Chart
{
public static void main(String[] args) throws Exception
{
String query = "SELECT Category, value from pieData2";
JDBCCategoryDataset dataset = new JDBCCategoryDataset(
"jdbc:mysql://localhost:3306/tabela", "com.mysql.jdbc.Driver",
"root", "root");
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart("Badanie Poziomu Cukru", "Numer Badania", "Poziom cukru",
dataset, PlotOrientation.VERTICAL, true, true, false);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
ApplicationFrame f = new ApplicationFrame("Chart");
f.setContentPane(chartPanel);
f.pack();
f.setVisible(true);
}
}
And when I click Chart button iam getting In my browser
HTTP Status 404 -
type Status report
message
descriptionThe requested resource () is not available.
Cheers