ServletOutputStream

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

ServletOutputStream

Post by Cristiano Leite » Thu Feb 27, 2003 8:21 pm

Hi,

I'm taking WebHitChart.java as sample code for my class.
When I run my class (HPSWebChart), using OverlaidVerticalCategoryPlot in Tomcat + IE6 + JDK1.4 in this code:

...
try{
// Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(jfreechart, 500, 300,session);

// Write the image map to the PrintWriter

ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
} catch (Exception e) {
System.out.println("Exception - " + e.toString());
e.printStackTrace(System.out);
filename = "public_error_500x300.png";
}
return filename;
...

Ocurr this error:

java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
at br.com.gerdau.HPSWebChart.generateChart(HPSWebChart.java:94)
at org.apache.jsp.index$jsp._jspService(index$jsp.java:66)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.ser....

I comment line: filename = ServletUtilities.saveChartAsPNG(jfreechart, 500, 300,session); (== HPSWebChart.java:94) and run, not make what I need, but run.

My JSP is this:

<%@ page import = "java.io.*" %>
<%@ page import = "br.com.acme.*" %>

<%
EstruturaExemplo ee = new EstruturaExemplo();
String filename = HPSWebChart.generateChart(ee.getExemplo(),session, new PrintWriter(out));
String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>
<html>
<head>
<title>HPSWebChart Exemplo</title>
</head>
<body>
<table border=0>
<tr>
<td>
<h2>Bar Chart Example</h2>
<img src="<%= graphURL %>" width=500 height=300 border=0 usemap="#<%= filename %>">
</td>
</tr>
</table>
</body>
</html>


Does anyone can help me???

Thanks,

Cristiano Leite

Cristiano Leite

Re: ServletOutputStream

Post by Cristiano Leite » Thu Feb 27, 2003 8:50 pm

A detail,
In sample jfreechart-0.9.6-sample.war, when I navigate to "Bar Chart Example" ocurr the same error.

This is a bug?

Tks,

Cristiano Leite.

Richard Atkinson

Re: ServletOutputStream

Post by Richard Atkinson » Thu Feb 27, 2003 9:50 pm

No, the class javax/servlet/ServletOutputStream is a core servlet class and should be accessible by your servlet engine. In a default Tomcat 4.1.x installation it appears in the [TOMCAT_HOME]/common/lib/servlet.jar. If your servlet engine cannot find that class it is misconfigured. I would recommend that you reinstall your servlet engine.

Regards,
Richard...

Cristiano Leite

Re: ServletOutputStream

Post by Cristiano Leite » Thu Feb 27, 2003 10:50 pm

Thanks, Richard.

I discovered a problem. I've put the file jfreechart-0.9.6.jar in the [JDK]\jre\lib\ext and in the ...webapp\hps\WEB-INF\lib.
When I remove .jar of the jre extensions, my app was ok.

Thanks.

Cristiano Leite

Locked