jspcompiler-errorsclasspath

JSP error: Only a type can be imported. x.y.Z resolves to a package


I get the error:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 7 in the generated java file Only a type can be imported. org.eresearch.knowledgeportal.model.Category resolves to a package

Someone has explained the cause here but I am not sure what I supposed to do to fix this. FYI: I am using Eclipse. I have added the code that does the importing below. The java.util.* import works fine.

 <%@ page import="java.util.*"%>
 <%@ page import="org.eresearch.knowledgeportal.model.Category"%>
 <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao"%>

 <% 
  CategoryDao catDao = new CategoryDao();
  ArrayList<Category> catList = catDao.selectCategory();

 //
 %>

Solution

  • OK I just solved it. In the last import I added a ";" by copying other code examples. I guess it's the standard line ending that is required.

    So

    <%@ page import="java.util.*" %>
    <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao" %>
    <%@ page import="org.eresearch.knowledgeportal.model.Category" %>
    

    became

     <%@ page import="java.util.*" %>
     <%@ page import="org.eresearch.knowledgeportal.dao.CategoryDao" %>
     <%@ page import="org.eresearch.knowledgeportal.model.Category;" %>