Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Doubt in syntax for taglib uri !!

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In .tld file generally we declare the uri as
<taglib ... >
...
<uri>someURIexample</uri>
<tag>
...
...
</tag>
</taglib..>

but in K&B book,Q-3 chapter 10,i found the declaration as
<taglib>
<taglib-uri>myTags</taglib-uri>
<taglib-location>/WEB-INF/myTags.tld</taglib-location>
</taglib>

i am totally puzzled with <uri> and <taglib-uri> Can you tell me what is difference between them and where they are used ?

With thanks in advance:

Prabhat
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Different versions of JSP.
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well the format:
<taglib ... >
...
<uri>someURIexample</uri>
<tag>
...
...
</tag>
</taglib>
is used in .tld file .
this kind of mapping is called implicit mapping(which is preferred as it requires less configuration).
to refer to a tag from this file we would use:
<%@taglib uri="someURIexample" prefix="myPrefix" %>
==========================================================
whereas the format below is used in Deployment Descriptor(web.xml)
<jsp-config>
....
<taglib>
<taglib-uri>myTags</taglib-uri>
<taglib-location>/WEB-INF/myTags.tld</taglib-location>
</taglib>
....
</jsp-config>

this kind of mapping is called explicit mapping.
to refer to a tag from this tld we would use:
<%@taglib uri="myTags" prefix="myPrefix" %>


However note that: explicit mapping takes precedence over implicit mapping, therefore if the uri element in first case and taglib-uri in second case have the same content, always the explicit mapping is used.
 
Prabhat Gupta
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Bear,
Can you elaborate it more precisely?? i.e which version uses <uri> and which one uses<taglib-uri> ?
 
Prabhat Gupta
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ash,
it is very useful to know about the explicit mapping and implicit mapping.

But as per i know the <uri> name should be unique for a web-application.According to you we can use same <uri> for implicit mapping as well as explicit mapping.Does it not violate its uniqueness ??? please correct me if i am wrong.
 
Ash More'
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, i tried using the same uri in taglib-uri element of web.xml and in uri element of a .tld file (am using Tomcat 6). Didnt get any errors .My observation was: the tag pointed by taglib-uri was given preference over the tag pointed by uri element of .tld file. Thus i observed that explicit mapping was preferred over implicit mapping, no errors when same uris were used.

read also my answers in following post :
how many uri in single .tld and same uri in different tlds

Also the specification says follows:
There should be no entries in web.xml with the same taglib-uri value.

hope am not confusing you.
[ April 21, 2008: Message edited by: Ash More' ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic