Reputation: 743
I am using a custom Tree Tag library to display hierarchical data by using the JSP taglib mechanism. My Tomcat setup has successfully deployed other webs apps including JSP & servlet samples, but it's giving me issues with this tag library. I have found this very same problem in a number of places but without responses. Any help is appreciated. Thanks in advance.
The tag library is declared as follows:
1: <%@ taglib uri="WEB-INF/treetag.tld" prefix="tree" %>
I've reduced my usage of this library to a single line for debugging purposes and that's the code at line 20. Here's the error message:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 20 in the jsp file: /hello.jsp
ITree cannot be resolved to a type
20: <% ITree tree = new Tree(); %>
From the above error, it looks like the server cannot find the library (jenkov-prizetags-3.4.0.jar) that I placed at webapp/WEB-INF/lib. I have unpacked the jar file and found the very same classes that the server cannot find, so I am inclined to think that it is just not looking in the webapp/WEB-INF/lib. Am I missing something here?
Programming Environment:
Upvotes: 0
Views: 771
Reputation: 1108537
Taglibs and scriptlets doesn't work together. You normally use the one or the other, not both.
As to the compilation error in your scriptlet, you just need to import the ITree
class like as you would do in a normal Java class.
<%@page import="com.example.ITree" %>
Or, better yet, don't use scriptlets at all. That Java code belongs in a Java class, not a JSP file.
Upvotes: 1