Custom tag works in top dir, breaks in subdirectory!
Hi:
My code works perfectly when the .jsp file is in the top level directory of the web app. However, when I move the file to a subdirectory:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: File "/hcctaglib" not found
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:565)
Any help would be amazing, thank you!
[399 byte] By [
jfalaschia] at [2007-11-26 18:13:36]

# 2
Hi, and thanks:
I'm sorry, I should have posted more detail. I'm just a bit -- stressed! :-)
In /WEB-INF/tlds/hcctaglib.tld:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>hcc</shortname>
<uri>/hcctaglib</uri>
<info>
A tab library
</info>
<tag>
<name>ifHasAccess</name>
<tagclass>com.hcc.taglib.SecurityCheck</tagclass>
<bodycontent>empty</bodycontent>
<info>Checks if the user has access</info>
<attribute>
<name>loginPage</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>collabID</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
</tag>
<tag>
<name>validateSession</name>
<tagclass>com.ora.jsp.tags.generic.ValidateSessionTag</tagclass>
<bodycontent>empty</bodycontent>
<info>
Forwards to the specified page if the session data is not available.
</info>
<attribute>
<name>name</name>
<required>true</required>
</attribute>
<attribute>
<name>loginPage</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>errorMsg</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
</taglib>
The .jsp file:
<%@ taglib uri="/hcctaglib" prefix="hcc" %>
<hcc:ifHasAccess loginPage="/login_cancer.jsp"/>
These were running fine on an old development server set up by someone else, years ago. That server is having numerous problems now, and we're migrating off of it. I've set up a new server, with the default install of tomcat 6. Obviously, I assume, I've set something up wrong. And now, the code works fine from the root dir of the webapp, but any other subdir and boom!
I'm assuming it's something small, something I've overlooked . . . but I'm pretty good at making big mistakes too, so nothing is for sure!
# 6
That's correct. You may try some of the following things.
1. Check that the tld file is indeed present in WEB-INF/tlds/
2. Ensure that the user has proper privileges on the directory and the file.
If the above is set up correctly, you may consider removing the <uri> element from the tld file. That really serves no purpose in your case.
And finally even if that doesnt work, try specifying a different uri.
Good luck.
ram.
# 7
Hi again:
It is in the dir, and permissions are properly set. It actually works when the file is in the top dir, but it can't find the .tld file when it's in the /pages/ dir.
From the pages dir, if I set the jsp page to a relative dir, using a dot dot to jump back up one dir, it works:
<%@ taglib uri="../WEB-INF/tlds/hcctaglib.tld" prefix="hcc" %>
<hcc:ifHasAccess loginPage="/login_cancer.jsp"/>
So the problem seems to be that the uri isn't using the top level of the web app as the start of the absolute uri. It did on the old install of tomcat, but I must not have tomcat set up correctly. Includes act correctly, but this taglib situation does not. What parameter in tomcat sets the top level dir for tag libs?
I'm pretty much a novice at setting up Tomcat, just used the default install. I'm so confused! I have a rather large sight with quite a bit of this login code used. I have to migrate the dev server, cuz the old dev server is history.
Thanks so much for your help.