Eclipse WTP: "Import ___ error cannot be resolved to" error in JSP file for class defined in project

Visual Studio user struggling with Eclipse ...

I imported a set of servlets / JSPs into a project in Oracle Workshop for Weblogic./page.jsp has the following import statement:

import="com.foo.bar.*" 

Eclipse displays an error message:

Import com cannot be allowed.

The class that implements the above import is located in /WEB-INF/src , but I do not know how to build the class in Eclipse to fix this error. I assumed that Eclipse will automatically create a .java file and put the output in /WEB-INF/classes , but it will not.

Maybe I didn’t structure my project directories correctly, which is why maybe Eclipse is not creating my source. Any suggestions? How can I make this work?

+2
source share
1 answer

First of all, /WEB-INF/src is a rather strange place to store your java sources; you can move them from /WEB-INF (for example, to /src in the project root)

In any case, you need to tell Eclipse where your sources are and where you need classes. This is done in the project properties dialog box:

  • Right-click the project in Eclipse, select "Properties"
  • Click on the Java build path on the left.
  • Click the source tab on the right.
  • Click the "Add Folder" button and add the source folder ( /WEB-INF/src or where you transferred it)
  • Make sure Allow output folders for source folders below
  • Once the source path has been added, select the output folder and point it to /WEB-INF/classes or another location of your choice.
+6
source

All Articles