Displaying Chart in JSP

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sakaray_c
Posts: 31
Joined: Mon Dec 22, 2003 11:35 am

Displaying Chart in JSP

Post by sakaray_c » Tue Feb 24, 2004 6:39 am

Hi,

I am displaying Chart in JSP page. I am using JRun App Server.

I am sending an example code of JSP page.

<html>
<head>
<title>Test</title>
</head>
<body bgcolor="#00ffff"> <!-- set background colour for page -->

Hello

<%

/**get the chart from request object which was got from servlet using RequestDispatcher*/

JFreeChart chart = (JFreeChart) request.getAttribute("CHART");
OutputStream ostream = response.getOutputStream();
ChartUtilities.writeChartAsJPEG(ostream, chart, 300, 300);
ostream.close();
%>

</body>
</html>

I am not getting the background color and i could not see "Hello" text too. Full page is converted as image. i.e., only chart is displayed. Pls tell me how to display a chart with background and text too. I want it without saving the chart. :cry:

regards,
sakaray_c

RCDran
Posts: 29
Joined: Wed Feb 25, 2004 4:18 am
Location: Japan

Post by RCDran » Wed Feb 25, 2004 10:05 am

Hi!

I too experienced the same problem and introduced frames to over come the problem.

You may also try the same. If you could some other work around could you post it?

--
RCDran

Locked