thedrs
thedrs

Reputation: 1464

Problems referencing an external project from my jsp - "ExternalClass cannot be resolved to a type"

I inherited 2 JSP projects (tomcat) in my eclipse with common code that is duplicated. I wanted to externalize the duplicate code to common library/project and reference it from both JSP project.

So I did the following:

I created a new Java project "JSP-Common" with the following package "com.mycompany.jsp.common". There I create a class "ExternalClass" with a public "test()" method that returns a string.

in JSP1 project(one of the 2 JSP projects):

  1. I added the JSP-Common project to the build path projects tab

  2. I added to the jsp file in it the following import:

    <%@ page import = "com.mycompany.jsp.common.*" %>
    
  3. I added to the jsp file in the body somewhere

    <% ExternalClass ec=new ExternalClass(); %>
    

After building and publishing the project, I get a "ExternalClass cannot be resolved to a type" error on the line with the instantiation above in my page.

Am I missing something ? Help ?

I want to make it so when I build my JSP1 project it will automatically take the callses from the JSP-Common project.

Upvotes: 5

Views: 2214

Answers (1)

e-zinc
e-zinc

Reputation: 4581

You have to add JSP-Common project in Deployment Assembly: go to Deployment Assembly page under project properties. Hit Add and select "Project" option.

Upvotes: 4

Related Questions