Reputation: 683
I'm trying to get my first jsp page running and it does not work as I expect it to. I'm using Tomcat7 + Eclipse.
First I created my framework.java file and put it in: \ROOT\WEB-INF\classes\framework.
Then I successful compiled it so I got: \ROOT\WEB-INF\classes\framework\Layer1.class, Layer2.class, Layer3.class Then i did the actual jsp file:
<%@ page import="framework.Layer1" %>
<%= Layer1.write() %>
Now, even Eclipse at this point gives me the warning: The type framework.Layer1 is not visible. And when I run the page, naturally it says: The type framework.Layer1 is not visible.
What am I doing wrong here? I tried all tutorials I found and all had the same issue. Any suggestions?
Upvotes: 0
Views: 4105
Reputation: 181460
You are in the right path, but you need to make sure Layer1 is a public class.
So, your Layer1
class must be something like:
package framework;
public class Layer1 {
public String write() {
return "hello";
}
}
Instead of:
package framework;
class Layer1 { // do note the non-use of public keyword here
}
Upvotes: 4