Bonjour ,
Besoin de votre aide
je travaille sur un projet et j'ai besoin d'afficher des courbes avec JSP
(j'ai deja telechargé et installé Jfreechart)
Voila mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.ChartUtilities" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.apache.jsp" %>
<%@ page import="org.jfree.data.jdbc.JDBCCategoryDataset"%>
<%@ page import ="java.util.Date,java.util.Locale,java.text.SimpleDateFormat,java.text.DateFormat,java.text.ParseException"
 contentType="text/html; charset=utf-8" %>
 
<%
 
 
String query="select to_char(date_appel,'dd/mm/yyyy') as date ,nombre_rejet,duree_rejet,round(pr_nbr)||'%',round(pr_duree)||'%' from pop_stat_date_emm_bscs where code_type_trafic= 'MO'";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("url","oracle.jdbc.driver.OracleDriver","user","pswd");
 
dataset.executeQuery(query);
JFreeChart chart = ChartFactory.createLineChart("nombre_rejet", "Id", "date",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);
 
try
{
ChartUtilities.saveChartAsJPEG(new File("C:/chart.jpg"), chart, 400, 300);
}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
%>


et voila le resultat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
exception
 
org.apache.jasper.JasperException: Impossible de compiler la classe pour la JSP: 
 
An error occurred at line: 21 in the generated java file
Only a type can be imported. org.apache.jsp resolves to a package
 
Une erreur s'est produite à la ligne: 21 dans le fichier jsp: /jsp/chart.jsp
ChartPanel cannot be resolved to a type
18: 
19: dataset.executeQuery(query);
20: JFreeChart chart = ChartFactory.createLineChart("nombre_rejet", "Id", "date",dataset, PlotOrientation.VERTICAL, true, true, false);
21:                 ChartPanel chartPanel = new ChartPanel(chart);
22:                 chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
23:                 ApplicationFrame f = new ApplicationFrame("Chart");
24:                 f.setContentPane(chartPanel);
 
 
Une erreur s'est produite à la ligne: 21 dans le fichier jsp: /jsp/chart.jsp
ChartPanel cannot be resolved to a type
18: 
19: dataset.executeQuery(query);
20: JFreeChart chart = ChartFactory.createLineChart("nombre_rejet", "Id", "date",dataset, PlotOrientation.VERTICAL, true, true, false);
21:                 ChartPanel chartPanel = new ChartPanel(chart);
22:                 chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
23:                 ApplicationFrame f = new ApplicationFrame("Chart");
24:                 f.setContentPane(chartPanel);
 
 
Une erreur s'est produite à la ligne: 23 dans le fichier jsp: /jsp/chart.jsp
ApplicationFrame cannot be resolved to a type
20: JFreeChart chart = ChartFactory.createLineChart("nombre_rejet", "Id", "date",dataset, PlotOrientation.VERTICAL, true, true, false);
21:                 ChartPanel chartPanel = new ChartPanel(chart);
22:                 chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
23:                 ApplicationFrame f = new ApplicationFrame("Chart");
24:                 f.setContentPane(chartPanel);
25:                 f.pack();
26:                 f.setVisible(true);
 
 
Une erreur s'est produite à la ligne: 23 dans le fichier jsp: /jsp/chart.jsp
ApplicationFrame cannot be resolved to a type
20: JFreeChart chart = ChartFactory.createLineChart("nombre_rejet", "Id", "date",dataset, PlotOrientation.VERTICAL, true, true, false);
21:                 ChartPanel chartPanel = new ChartPanel(chart);
22:                 chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
23:                 ApplicationFrame f = new ApplicationFrame("Chart");
24:                 f.setContentPane(chartPanel);
25:                 f.pack();
26:                 f.setVisible(true);
 
 
Stacktrace:
	org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
	org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
	org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
J'ai pas comris exactement c'est quoi le probleme