• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i think there's a bug on the manning book

 
luis meira
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,
i've been studying hard for the certification and right now i'm taking a closer look at the custom tags.
after some carefull reading of both jsp 1.2 specification and the maning book i think i found a bug on the manning book.
this book states that when you deploy a tag in jar you have to put the tld in the META-INF directory, and the tld must be called taglib.tld. according to jsp specification this is was true for the old specification ( JSP.7.2.1 ) on the new specification you can had more than on tld file in the META-INF.
this means that you can deploy more than one tag for jar.
best regards
Luis Meira
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have the Manning book, but what you state here is essentially correct. There is a "but", though.
  • If in the deployment descriptor (web.xml) you map a taglib URI to a jar, the TLD used will be META-INF/taglib.tld in the jar.
  • By the same token, multiple TLDs in a jar only make sense if these TLDs specify a taglib URI so you can actually refer to them.
  • HTH,
    - Peter
     
    luis meira
    Ranch Hand
    Posts: 55
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Your right.
    when i tested several tld in META-INF i had Specify <uri></uri> in the tld.
    thanks for the correction.
    Luis Meira
    Originally posted by Peter den Haan:
    I don't have the Manning book, but what you state here is essentially correct. There is a "but", though.
  • If in the deployment descriptor (web.xml) you map a taglib URI to a jar, the TLD used will be META-INF/taglib.tld in the jar.
  • By the same token, multiple TLDs in a jar only make sense if these TLDs specify a taglib URI so you can actually refer to them.
  • HTH,
    - Peter
     
    Jessica Sant
    Sheriff
    Posts: 4313
    Android IntelliJ IDE Java
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Two things:
  • Check the book's online errata I couldn't seem to find it... but I might have not looked hard enough.
  • Post to the authors online -- they're pretty good at responding and if you find an error -- they'll update the errata. (You've gotta get a username/password if you want to search or post to the board)


  • [ November 20, 2002: Message edited by: Jessica Sant ]
     
    Jignesh Malavia
    Author
    Ranch Hand
    Posts: 81
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi!
    I just replied here.
    Thanks for mentioning the links Jessica.
    Originally posted by luis meira:
    when i tested several tld in META-INF i had Specify <uri></uri> in the tld.

    What naming convention did you use for the TLD files if they were all under the same directory? Or did you use multiple sub-directories under META-INF?
    Regards
    -j
     
    luis meira
    Ranch Hand
    Posts: 55
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    i everybody
    i created 3 diferent tld teste1.tld, teste2.tld and teste3.tld exacly under META-INF.
    i named the resulting the jar mytags.jar.
    from what i can tell it's like this :
    <%@taglib prefix="buga" uri="/WEB-INF/lib/mytags.jar" %>
    this doesn't work, you can only use a direct uri to a jar if taglib.tld exists in the META-INF.
    if you change the web.xml like this :
    <taglib>
    <taglib-uri>/xpto</taglib-uri>
    <taglib-location>/WEB-INF/lib/mytags.jar</tablib-uri>
    </taglib>
    and of course change the following :
    <%@taglib prefix="buga" uri="/xpto" %>
    this doesn't work for the same reason i gave before.
    but if u change each one of the tld's and include a
    uri tag it will work like a charme becaus when tomcat load's the jar it automaticaly creates a taglib map for each tag.
    for example :
    adding this to the teste.tld
    <uri>/xpto</uri>
    and then updating the tag directive
    <%@taglib prefix="buga" uri="/xpto" %>
    this will work i haven't tried it on any other application server so i can't tell if it's only a tomcat thing or no.
    best regards
    Luis Meira
     
    Peter den Haan
    author
    Ranch Hand
    Posts: 3252
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Luis, that's indeed how it is supposed to work.
    - Peter
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic