Packaging Multiple Libraries in One JAR File
A beneficial side effect of the auto-discovery feature is that you can bundle more than one tag library in the same JAR file. In JSP 1.1, a TLD contained in a JAR file had to be named exactly META-INF/taglib.tld, which meant that a JAR file could contain only one TLD.
The auto-discovery feature, however, treats any file with a .tld extension in a JAR file’s META-INF directory as a TLD. You can therefore put multiple TLDs (along with the class files for the libraries) in one JAR file. This makes it easier for your users to deploy related tag libraries. Note that you must use the auto-discovery mechanism to deploy multilibrary JAR files, because there’s no way to specify the path to an individual TLD in such a JAR file.[3]
[3] You can deliver the TLDs separate from the JAR
file and require that they be mapped with
<taglib> elements in the application
deployment descriptor as well, but that defeats the purpose of making
deployment easy.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access