Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt about TLD

 
Prabhat Gupta
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • 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 ]
 
Garlapati Ravi
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic