• 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 about TLD

 
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 All,

Is it valid to define more than one <uri> in a single .tld file?
Can we define more than one <tag> in single .tld file ?
Can we have more than one .tld file inside WEB-INF ?

I guess if we can do second one then we must define same <uri> for all tag in tagdirective.

For the third one , suppose that we have two tld file say first.tld and second.tld and each have same uri and name but different content(tag-class) like
<taglib ...>
<uri>myUri</uri>
<tag>
<name> myTag </name>
---
---
</tag>
</taglib>

and i hvae one .jsp having declaration as
<%@taglib prefix="myPrefix" uri="myUri" %>
<myPrefix:myTag/>
-----
------

in this case which tag (more appropriate tag-class) will be chosen?

Thanks,
Prabhat

[ May 17, 2008: Message edited by: Prabhat Gupta ]
[ May 17, 2008: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Is it valid to define more than one <uri> in a single .tld file?


No.

Can we define more than one <tag> in single .tld file ?


Yes.

Can we have more than one .tld file inside WEB-INF ?


Yes.

I guess if we can do second one then we must define same <uri> for all tag in tagdirective.


Yes.

in this case which tag (more appropriate tag-class) will be chosen?


In this case you would get runtime exception, as the the same URI repeated in two different .tld files, the container will be in ambiguity state in choosing .tld file, and throws exception at runtime. so you have to specify to container to choose a perticular tld(using attributes tagdir or uri with relative path of .tld),
[ May 17, 2008: Message edited by: Garla Ravi ]
 
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 Ravi,

so you have to specify to container to choose a perticular tld(using attributes tagdir or uri with relative path of .tld)



As per i know we don't use attribute "tagdir" for Tag handler class (Yes, we can use same for TAG FILE ).

In order to find out the location of .tld file through <uri> ,Container will look first in our DD to see whether we have made any <taglib> entries . if it has , then it will use those to help construct the map. if NO ,then it will search inside some specific folder.
Correct me if i am wrong.

One more question, is it necessary to place the .tld file in those specific location. I guess in older version of JSP we can place it any where and just mention its right address in <taglib-location> .
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Correct me if i am wrong.


you were correct

is it necessary to place the .tld file in those specific location


Need not be. If you place in those specific locations, container will do mapping.

can place it any where and just mention its right address in <taglib-location>


that's correct.
[ May 18, 2008: Message edited by: Garla Ravi ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic