Hi, I am a new user, i started using jfree from last week, i have been using jfreechart to output the results in a graphical format. I am trying to retrieve the output data from the SQL database and i am using the JDBCXYDataset for it. Here is the java code
JDBCXYDataset data = null;
try
{
data = new JDBCXYDataset(connect);
String sql1 = "SELECT year,somtc,totc FROM NebraskaRunsTemp WHERE surftext = '" + surftext + "' AND base = '" + base + "' AND recent = '" + recent + "' AND hydric = '" + hydric + "' AND method1 = '" + method1 + "' AND method2 = '" + method2 + "' AND rotation1 = '" + rotation1 + "' AND rotation2 = '" + rotation2 + "'";
data.executeQuery(sql1);
JFreeChart chart = ChartFactory.createTimeSeriesChart("Sample XY Chart","Year","Somtc",data1,true,true,false);
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(out, chart, 400, 300);
}
I get this following error
C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\coreservlets\ViewResults_jsp.java:193: cannot resolve symbol
symbol : method writeChartAsPNG (javax.servlet.jsp.JspWriter,org.jfree.chart.JFreeChart,int,int)
location: class org.jfree.chart.ChartUtilities
ChartUtilities.writeChartAsPNG(out, chart, 400, 300);
I don't know what i am doing wrong here. Any help will be appreciated.
Thanks
Can't display the chart in jsp
text - image - text again
if I write some text in my jsp, then use code like this (see below), then write some text again, then I receive "text - garbage - text" on my html page.rfuller wrote://try
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 400, 300);
//rather than
//ChartUtilities.writeChartAsPNG(out, chart, 400, 300);
maybe I need to use response.setContentType("image/png") another way here? the garbage starts with symbols "‰PNG ", so it looks like a valid PNG file, this should be printed as an image, not just typed as a text.
Code: Select all
<%
JFreeChart chart = (JFreeChart) request.getAttribute("my_chart_blin");
response.setContentType("image/png");
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 600, 300);
%>
another way
maybe it is possible to perform the page include - like
... JSP here ...
page include - get the jpeg image with content type image/jpeg
... text from jsp again...
... JSP here ...
page include - get the jpeg image with content type image/jpeg
... text from jsp again...
-
- Posts: 26
- Joined: Fri May 09, 2003 4:55 am
- Location: Tasmania, Australia
- Contact:
Cewolf Project
Hi
Just a note to let you know that the cewolf project (a jsp tag library for jfreechart) will be adding support for the jdbcDatasets soon.
I do not have direct cvs access but first version of the code has been submitted to the project administrator and I am about to submit the first patch to the code.
Bryan
Just a note to let you know that the cewolf project (a jsp tag library for jfreechart) will be adding support for the jdbcDatasets soon.
I do not have direct cvs access but first version of the code has been submitted to the project administrator and I am about to submit the first patch to the code.
Bryan
Bryan