I have a jar file that contains some tag-files.
My *.tag
files are inside /META-INF/tags/
folder (jar)
I also have a mytags.tld
inside /META-INF/
folder (jar)
After pack all war
project (with mytags.jar
inside WEB-INF/lib
folder), it works fine in JBoss. But Eclipse still cannot recognize the tag, getting the error Can not find the tag library descriptor for "http://www.mycompany.com"
Is there a way to Eclipse recognize my tags?
follow the sources:
block.tag
<%@tag description="Item do block" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@attribute name="id" required="true" %>
<%@attribute name="label" required="true" %>
<%@attribute name="description" required="false" %>
<%@attribute name="icon" required="false" %>
<div id="${id}" class="block">
<div class="block-box ${icon}">
<div class="label">
<span>${label}</span>
</div>
<div class="description">
${description}
<jsp:doBody></jsp:doBody>
</div>
</div>
</div>
mytags.tld
<?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">
<description>My Tags</description>
<display-name>MyTags</display-name>
<tlib-version>1.0</tlib-version>
<short-name>mytags</short-name>
<uri>http://www.mycompany.com</uri>
<tag-file>
<name>block</name>
<path>/META-INF/tags/block.tag</path>
</tag-file>
</taglib>
some.jsp
<%@page contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.mycompany.com" prefix="mytags" %> <-- ECLIPSE MARKS ERROR HERE
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<mytags:block id="users" label="Users" icon="user">
<!-- some content -->
</mytags:block>
</body>
</html>
But everything works fine in JBoss. Only eclipse accuses error.
Thanks
An existing bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=330405 suggests correcting the error message to point to the JSP version 1.1 detected from web.xml as a reason for the outdated interpretation of the taglib URI.
This is confirmed by a JSP Tag Libraries document, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1014427:
Both of the above 2 conventions retired to a fallback mechanism since JSP 1.2 which introduced mapping tag definitions and uses through the arbitrary taglib uri strings, http://docs.oracle.com/cd/B14099_19/web.1012/b14014/taglibs.htm#i1013109.
A recent JSP 2.1 spec documents the URI mapping in section JSP.7.3.2: