I m getting problem in displaying charts and m not exactly able to find the problem
plz plz help me wher i m wrong plzzzzzzzzzzzzzzzzzzzzzzz
its very urgent............--------
---------------------
package src;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.servlet.http.HttpSession;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.data.XYDataset;
import org.jfree.data.XYSeries;
import org.jfree.data.XYSeriesCollection;
public class WebHitChart {
public static String generateXYChart(HttpSession session,
PrintWriter pw) {
String filename = null;
try {
final String query = "select target_milestone,dre from dre_cal where product='WEBSITES' ";
Connection conn;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:dreDSN");
Statement statement = conn.createStatement();
System.out.println("the value of conn ...." + conn);
System.out.println("start");
ResultSet rs = statement.executeQuery(query);
XYSeries series = new XYSeries("Average Weight");
while (rs.next()) {
series.add(rs.getInt(1), rs.getInt(2));
}
XYDataset xyDataset = (XYDataset) new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart(
"XYLine Chart using JFreeChart", "Age", "Weight",
xyDataset, PlotOrientation.VERTICAL, true, true, false);
ChartRenderingInfo info = new ChartRenderingInfo(
new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info,
session);
// Write the image map to the PrintWriter
ChartUtilities.writeImageMap(pw, filename, info, false);
pw.flush();
} catch (Exception e) {
System.out.println("Exception - " + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}
return filename;
}
------------------------------------------------------
<%@ page import = "src.*" %>
<%@ page import = "java.io.PrintWriter" %>
<%
String filename = WebHitChart.generateXYChart(session, new PrintWriter(out));
String graphURL = request.getContextPath() + "/WebHitChart.do?filename=" + filename;
%>
<html>
<body>
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>">
</body>
</html>
------------------------------------------------------------
<servlet>
<servlet-name>somename</servlet-name>
<servlet-class>src.WebHitChart</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>somename</servlet-name>
<url-pattern>/WebHitChart.do</url-pattern>
</servlet-mapping>
---------------------------------
Error i m getting on jsp page is
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /xy_area.jsp at line 4
1: <%@ page import = "src.*" %>
2: <%@ page import = "java.io.PrintWriter" %>
3: <%
4: String filename = WebHitChart.generateXYChart(session, new PrintWriter(out));
5: String graphURL = request.getContextPath() + "/WebHitChart.do?filename=" + filename;
6: %>
7: <html>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/jfree/data/XYDataset
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.xy_005farea_jsp._jspService(xy_005farea_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
java.lang.NoClassDefFoundError: org/jfree/data/XYDataset
org.apache.jsp.xy_005farea_jsp._jspService(xy_005farea_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
--------------------------------------------------------------------------------