Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 220
thedrs Avatar asked Oct 08 '22 22:10

thedrs


1 Answers

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

like image 166
e-zinc Avatar answered Oct 13 '22 12:10

e-zinc