Using JSP's

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Neil

Using JSP's

Post by Neil » Mon Apr 08, 2002 10:33 am

Hi,

I'm having trouble using the taglibs for JSP's and I was wondering is it possible to just pass the JFreeChart object to the JSP in a request and then call the ChartUtilities.writeChartAsJPEG () method passing the appropriate arguments. Has anyone tried to do this? Would anyone know another way of doing it without using the taglibs?

Any help would be much appreciated.

NEIL

Neil

Re: Using JSP's

Post by Neil » Mon Apr 08, 2002 1:44 pm

Its OK - problem solved

NEIL

Sang

Re: Using JSP's

Post by Sang » Wed Apr 10, 2002 12:03 am

Hi,
Recently I started with JFreeChart. I am also a problem calling the servlet from the jsp page. It says NoClassFound. I was using it as an action to form submit. I think I am missing somthing with the stettings. I am using tomcat as the server. I did the required settings in the web.xml for the servlet.
Any Suggestions. Thnx in advance.
Sang

charlotte

Re: Using JSP's

Post by charlotte » Wed Apr 10, 2002 5:44 pm

hi,
i am in the ame case, i begin with Java and with JFreeChart.

chart.draw(g2, new Rectangle2D.Double(0, 0, 400, 300), new com.jrefinery.chart.DrawInfo());
OutputStream out=System.out;
File file = new File("e:\Esaip\test.jpg");
com.jrefinery.chart.ChartUtilities.saveChartAsJPEG(file, chart, 2, 2);
com.jrefinery.chart.ChartUtilities.writeChartAsJPEG(out, chart, 2, 2);

out.flush();
out.close();

i tried differents methods, nut no one works,
thanks for help,

charlotte.

Neil

Re: Using JSP's

Post by Neil » Fri Apr 12, 2002 4:47 pm

The best way to solve your problem is to follow the JFreeChartServletDemo. Narrow down to your specific case. I retrieve my data from a database for my axis values.

So for example when I used a XYDataSet for my chart, I had:

JFreeChart chart = createChart(type, initGradColor, finalGradColor);

In the createChart() method, pass the data you want to store as an argument when creating the dataset:

XYDataset xyData = createXYData(data) //data is my data from database;

All you need to do is make your data specific to the servlet demo.
Save your chart the way you have been and display it on your JSP by inserting the image

If you have any more questions- I'll do my best!!

NEIL

Locked