Page 1 of 1

About <taglib> element in the web.xml doubt ?

Posted: Thu Jan 03, 2013 8:52 am
by gurpreet_asrgndu
Consider i have a tld file hello.tld with a uri tag in it as <uri>guru</uri>. i put this .tld file in WEB-INF directory. also i put a taglib element in web.xml as follows :

<taglib>
<taglib-uri> test </taglib-uri>
<taglib-location>/WEB-INF/hello.tld</taglib-location>
</taglib>

my question is which mapping will container choose : test -----> /WEB-INF/hello.tld OR

guru---->/WEB-INF/hello.tld OR both will be loaded.

question no. enthuware.jwpv6.2.1053 explanation says that :
Note that the mapping information contained within the tld file will always be loaded by the container. The <taglib> tag in web.xml is used to provide any additional taglib-uri mappings. And for those additional mappings, you will need to specify the taglib-location.

Re: About <taglib> element in the web.xml doubt ?

Posted: Thu Jan 03, 2013 1:45 pm
by admin
The URIs are only used to identify which tag library is being used. So you can have mutliple uris pointing to same tag lib.

What you cannot have is same uri pointing to different tag libraries.

Please take a look at Section JSP 3.2 (Taglib Map) and JSP 7.2.3 (Tag Library directive) to understand how this works.

HTH,
Paul