1

I have a simple JSP file in the WebContent folder of an Eclipse generated web project. I am trying to create a reference from this to a Test class but I keep getting a compilation error - "Test cannot be resolved to a type".

I tried to reference it by using:

Test t = new Test();

and then I added

<%@page import="Test"%>

and it still didn't work. So I tried to pre-compile the .java file, then I tried to copy it in the src folder, the WEB-INF/classes and the WebContent folders. Then I created a WEB-INF/classes/actions folder and copied the class and source file there too. I tried to modify the import statement to reflect each of these locations but the compile was unable to find the class in either of them.

So, I'm running out of ideas. Where am I going wrong?

Ok solved it. Here's what I was doing wrong: I blindly followed some old tutorial and copied the same pre-compiled file in places where it didn't belong. And the one time I copied it in the right place it didn't work because it didn't have the correct package declaration. What I did is I cleared out my project and let eclipse create packages in the right places and files with the proper declarations and it worked.

spacitron
  • 2,095
  • 7
  • 30
  • 39

0 Answers0