Reputation: 13
**Hello,friends. I met a problem when I try to visit the jsp page .
my jsp import some jars
<%@ page import="org.jfree.data.general.DefaultPieDataset,org.jfree.chart.ChartFactory
,org.jfree.chart.JFreeChart,org.jfree.chart.servlet.*" %>
Tomcat debug display :**
Servlet.service() for servlet [jsp] in context with path [/Test] threw exception [Unable to compile class for JSP:
An error occurred at line: [14] in the generated java file: [/Users/JinCan/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/work/Catalina/localhost/Test/org/apache/jsp/jfreeChart_jsp.java] Only a type can be imported. org.jfree.data.general.DefaultPieDataset resolves to a package
An error occurred at line: [15] in the generated java file: [/Users/JinCan/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/work/Catalina/localhost/Test/org/apache/jsp/jfreeChart_jsp.java] Only a type can be imported. org.jfree.chart.ChartFactory resolves to a package
An error occurred at line: [16] in the generated java file: [/Users/JinCan/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/work/Catalina/localhost/Test/org/apache/jsp/jfreeChart_jsp.java] Only a type can be imported. org.jfree.chart.JFreeChart resolves to a package
An error occurred at line: 20 in the jsp file: /jfreeChart.jsp DefaultPieDataset cannot be resolved to a type
I have already put the jars in WEB-INF/lib how do I change ?
Upvotes: 1
Views: 4355
Reputation: 9197
Use (more readable) for SO:
<%@ page import="org.jfree.data.general.DefaultPieDataset" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
You can only import a type, so this will not work:
<%@ page import="org.jfree.chart.servlet.*" %>
And make sure jfree library is included:
<!-- https://mvnrepository.com/artifact/jfree/jfreechart -->
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
Upvotes: 1