Reputation: 3972
I have an interesting issue... I am trying to add a JSP Tag to my application. I have stored a functions.tld
in /WEB-INF/tags/
but I get the error message Illegal TLD path /WEB-INF/tags/functions.tld, must not start with "/WEB-INF/tags"
so I tried to move it /WEB-INF/
which I then get Tag file directory /WEB-INF/functions.tld does not start with "/WEB-INF/tags"
. So where am I supposed to put it!!
TLD File
<?xml version="1.0" encoding="UTF-8"?>
<taglib xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
version="2.1">
<tlib-version>1.0</tlib-version>
<short-name>my</short-name>
<!-- Invoke 'Generate' action to add tags or functions -->
<function>
<name>urlencode</name>
<function-class>library.StringUtils</function-class>
<function-signature>java.lang.String urlencode(java.lang.String)</function-signature>
</function>
</taglib>
JSP File
<%@ taglib prefix="f" tagdir="/WEB-INF/tags/functions.tld" %>
Error when not in tag folder
org.apache.jasper.JasperException: PWC6191: Tag file directory /WEB-INF/functions.tld does not start with "/WEB-INF/tags"
Error when in /tag/ folder
Error invoking ServletContainerInitializer org.apache.jasper.runtime.TldScanner
org.apache.jasper.JasperException: PWC6336: Illegal TLD path /WEB-INF/tags/functions.tld, must not start with "/WEB-INF/tags"
at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:573)
at org.apache.jasper.runtime.TldScanner.processTldsInFileSystem(TldScanner.java:566)
at org.apache.jasper.runtime.TldScanner.scanTlds(TldScanner.java:354)
at org.apache.jasper.runtime.TldScanner.onStartup(TldScanner.java:242)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5713)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:623)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5609)
at com.sun.enterprise.web.WebModule.start(WebModule.java:540)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:900)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:684)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2044)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1690)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:107)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
Startup of context failed due to previous errors]]
Upvotes: 1
Views: 3008
Reputation: 5284
It is a simple misunderstanding. Reasoning about it a little, it does not make much sense to use an attribute tagdir to refer to a single tag file. The correct way to achieve it is to indeed put the TLD file in the WEB-INF directory and then refer to it using
<%@ taglib prefix="f" uri="/WEB-INF/functions.tld" %>
In other words: replace tagdir with uri.
This existing question and answer explains the difference.
Upvotes: 2