2

I have defined two .tld files under WEB-INF but both of them has the same <URI> say "XYZ".

I declared in the JSP <%@ taglib prefix="mine" uri="XYZ" %>" .

How does container resolve the ambiguity as to which tld file to read to get the function class and function definition?

EDIT : I ran it in Tomcat 7 and it didn't throw exception.

Roman C
  • 49,761
  • 33
  • 66
  • 176
AllTooSir
  • 48,828
  • 16
  • 130
  • 164
  • 1
    Can anyone tell me why is the down vote for , why don't you answer the question if you think it was such a trifle query rather than down voting !!!! – AllTooSir Jan 30 '13 at 10:28

1 Answers1

2

It'll load the first match found in classpath. The order is JVM and OS dependent (and essentially arbitrary). You don't want to rely on that and you should fix the .tld URIs.

If this represents a real world problem and the taglib code is outside your control (which is however quite strange, who would ever copy an URI of an existing taglib? do you really own the other taglib's domain?), then you can always redefine taglib URIs in webapp's web.xml as follows:

<taglib>
    <taglib-uri>http://www.example.com/foo</taglib-uri>
    <taglib-location>/WEB-INF/foo.tld</taglib-location>
</taglib>
<taglib>
    <taglib-uri>http://www.example.com/bar</taglib-uri>
    <taglib-location>/WEB-INF/bar.tld</taglib-location>
</taglib>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Sorry , I was just trying to understand the working of taglibs , nothing to do with real world problem but out of inquisitiveness . – AllTooSir Jan 29 '13 at 16:47