Struts 1 - struts-taglib.jar is not being found by my web application
You say the JAR does appear in the WEB-INF/lib for the web app; I'll take your word for it and believe you.
I would suggest that you open up the struts-taglib.jar
, open the .tld for the tag library, and verify that the <uri> value that you find under the <taglib> root matches the uri for the given prefix in your JSPs. I'm guessing that the URI doesn't match, which means the class loader won't be able to find the tag library even if the JAR is in the CLASSPATH.
It might also indicate whether or not a version change made the URI in your JAR and JSP out of synch.
I just downloaded struts-1.3.10-all.zip and looked at the struts-logic.tld contained within. The value of the <uri>
tag is http://struts.apache.org/tags-logic
, so it looks like you're okay there.
The .tld files look like they're externalized from the JAR. Look for them under .\src\el\src\main\resources\META-INF\tld, put them in your /WEB-INF, and refer to them explicitly in your web.xml. That should sort you out.
I don't believe .tld in web.xml is necessary anymore, but if the URI thought doesn't pan out you can try adding something similar to this example from "JSTL In Action" to your web.xml (modified accordingly):
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/c.tld</taglib-location>
</taglib>
It could be because Struts 1.0 is rather old at this point. Packaging the .tld in the JAR of the taglib became a common practice after Struts 1.0 was developed.
Amit
Updated on June 04, 2022Comments
-
Amit almost 2 years
I am using
Struts-1
. I have developed a struts-based web application. I am using struts tags in my JSP pages supplied instruts-taglib.jar
by inserting the following lines in the JSP file:<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %> <%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %> <%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
Now the application is working fine when I run it on my localsystem but when I deploy it on a server, it shows the following exception:
org.apache.jasper.JasperException: The absolute uri: http://struts.apache.org/tags-html cannot be resolved in either web.xml or the jar files deployed with this application
From the above exception, it seems that the application hasn't found the
struts-taglib.jar
file.But I have put the
struts-taglib.jar
in/WEB-INF/lib
directory. Then where is the problem?Note: You can also look at Java - Problem in deploying Web Application for more information
-
Amit about 14 yearsI think that it is the default classpath of any web application. Should there be any file that defines the classpath(s) any web application. My application doesn't have any such file. I developed it in Eclipse and in Eclipse yes `/WEB-INF/lib was in my classpath.
-
duffymo about 14 yearsExactly. You don't need to changed anything to get WEB-INF/lib and WEB-INF/classes in your web app CLASSPATH. It's the default.
-
lzap over 13 yearsPlease note URI has changed since version 1.2!
-
Rumel over 7 yearsI was getting this error despite having the jar present. Then fixed according to your answer and it has fixed the error.