Just recently I discovered a simple problem in our application around the packaging of custom taglibs in JARs. Looking into the issue, it seems that the ".tld" files were placed in the /WEB-INF/tld folder in the JAR! That is wrong. The correct way to do it is…
source: JSP 1.2 Specification (see references below)
JSP.7.3.1 Identifying Tag Library Descriptors
Tag library descriptor files have names that use the extension ".tld", and the extension indicates a tag library descriptor file. When deployed inside a JAR file, the tag library descriptor files must be in the META-INF directory, or a subdirectory of it. When deployed directly into a web application, the tag library descriptor files must always be in the WEB-INF directory, or some subdirectory of it.
Articles listed in the References (see below) discuss the details of specifying uri in taglib descriptor and referring taglibs using absolute URI without the need to create aliases in web.xml. Eventhough this feature is couple of years old, there still seem to be some issues around the support of this feature by some servlet containers. But as far as I know it works with WebSphere and Tomcat.
If you are wondering what good these absolute URI’s do, refer to the JSP 1.2 Spec for more details. It pays to read the specs once in a while!
- JSP best practices: Pack ’em up!
- Dry your taglib URIs
- If you are planning to build a new custom tag library, take a look at Jakrata Taglibs. May be you will find something useful. If you like them, continue on to Jakarta Taglibs Tutorial
- JSR 53: JavaTM Servlet 2.3 and JavaServer PagesTM 1.2 Specifications
- JSR 154: JavaTM Servlet 2.4 Specification
- JavaServer Pages Standard Tag Library
- JSR 52: A Standard Tag Library for JavaServer PagesTM
Latest posts by Content Team (see all)
- IndicThreads Pune 2016 To Equip Developers For A New Age Of Software Development - May 27, 2016
- Java Garbage Collectors – Moving to Garbage First (G1) Collector - May 25, 2016
- Using Lambdas and Streams in Java 8 - May 18, 2016