facebook

"No tag" error on JSP page

  1. MyEclipse IDE
  2.  > 
  3. Java EE Development (EJB, JSP, Struts, XDoclet, etc.)
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #237266 Reply

    korzh
    Member

    Situation:

    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?

    #237412 Reply

    Riyad Kalla
    Member

    First read this:
    http://www.myeclipseide.com/FAQ+index-myfaq-yes-id_cat-31.html#251

    Then 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.

Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: "No tag" error on JSP page

You must be logged in to post in the forum log in