- This topic has 1 reply, 2 voices, and was last updated 19 years, 2 months ago by Riyad Kalla.
-
AuthorPosts
-
korzhMemberSituation:
I have created a sample web project which contains one custom tag and one JSP page that uses that tag. My project folders are:
root |_src | |_tags | |_CounterTag.java | |_WebRoot | |_WEB-INF | |_tlds | | |_counter.tld | |_web.xml |_ hello.jsp
counter.tld file contains the description of the tag:
. . . . . . <taglib> . . . . . . <tag> <name>counter</name> <tagclass>tags.CounterTag</tagclass> <bodycontent>empty</bodycontent> </tag> </taglib>
The hello.jsp file contains the following code:
<body> <%@ taglib uri="WEB-INF/tlds/counter.tld" prefix="util" %> This page was accessed <b><util:counter/></b> times. </body>
On the row where counter tag is used Eclipse shows the following error:
‘No tag “counter” defined in tag library imported with prefix “util”‘If I deploy the page on the server and open it in web-browser everything works fine but this error is just annoying. Can I fix it somehow?
Riyad KallaMemberFirst read this:
http://www.myeclipseide.com/FAQ+index-myfaq-yes-id_cat-31.html#251Then add a taglib mapping to your web.xml file like this:
<jsp-config> <taglib> <taglib-uri>/tags/counter</taglib-uri> <taglib-location>/WEB-INF/tlds/counter.tld</taglib-location> </taglib> </jsp-config>
Then change your @taglib entry in your JSP file to look like this:
<%@ taglib uri="/tags/counter" prefix="util" %>
NOTE: The “taglib-uri” in your web.xml file and the one specified in your JSP page are just strings, but they must match. You can leave it as /WEB-INF/tlds/counter.tld if you like, but you need to have matching Strings.
After you have done that, save and rebuild your project, if the error persists, restart MyEclipse, we have a tld caching bug that sometimes forget to update the TLD cache.
-
AuthorPosts