Independent Programmer - Technology Enthusiast - JUG Leader from JUG Joglosemar
Yosi Pramajaya wrote:Hello, I want to take an OCEWCD Java EE 6.
But, I want to ask something when I learn from a book.
Where's the exact location of a .tld files?
I've read a topic, that said it only can be located in WEB-INF directory or it's subdirectory.
But I've read here Oracle's DOCS.
That said we can include .tld in META-INF directory or it's subdirectory.
Now, what's the exact position of .tlds?
Frits Walraven wrote:Hi Guys,
To be a little more precise, these are the general rules:
The TLD file
Explicit mapping:
the taglib directive in a JSP-file has an URI that corresponds with a <taglib-uri> in the <taglib> element of the web.xml. The location of the TLD file is found in the <taglib-location> element.
Implicit mapping:
the taglib directive in a JSP-file has an URI that doesn't match any <taglib-uri> in the <taglib> element of the web.xml. The JSP container gets the location by searching the subdirectories of /WEB-INF and the jar's in /WEB-INF/lib for a TLD file with a matching URI.
the fallback rule allows a taglib directive to refer directly to the TLD. This arrangement is very convenient for quick development at the expense of less flexibility and accountability. For example: <%@ taglib uri="/WEB-INF/tlds/PRlibrary_1_4.tld" prefix="x" %>
The URI in the taglib directive doesn't point to anything (with exception of the fallback-rule) it only has to match the corresponding <taglib-uri> setting in the web.xml or the optional <uri> attribute in the TLD-file.
The .tld files within a jar file must have a path that begins with /META-INF
Regards,
Frits
what frits said , those rules are in J2EE 1.4.. In J2EE 6, drop your tld file in WEB-INF (or) sub-directory of WEB-INF (or) in META-INF. refer the tld file in jsp using uri in tld file. server is smart enough to detect the tld file. instead of uri, can also use tld location.
Frits Walraven wrote:
If you check the JSP 2.2 specs which is part of EE6, you will still find all of the general rules (from JSP.7.3 The Tag Library Descriptor onwards)
Regards,
Frits
I thought J2EE 6 has jsp 2.3 specification.Thanks Frits , for correcting me.