web.xml: taglib element not needed since JSP 2.0 

Joined:
04/09/2007
Posts:
753

February 11, 2010 00:39:57    Last update: February 11, 2010 00:39:57
The <taglib> element is no longer needed in web.xml since JSP 2.0. Since the location of TLD files are not specified, the servlet container searches for them in these places:
  • Under the /WEB-INF folder
  • Sub folders of the /WEB-INF folder
  • Inside JAR files under /WEB-INF/lib - in the META-INF folder inside the JAR.


Usually the TLD files are packaged with the tag library class files in the same JAR. For example, the TLD files for the standard JSTL tags can be found in standard.jar/META-INF.

How do you use a custom tag in a JSP then? You use the same uri as declared in the TLD in the taglib declaration of your JSP. For example, the JSTL core tags TLD (c.tld) looks like this:
<description>JSTL 1.1 core library</description>
  <display-name>JSTL core</display-name>
  <tlib-version>1.1</tlib-version>
  <short-name>c</short-name>
  <uri>http://java.sun.com/jsp/jstl/core</uri>
  .
  .
  .


You'd reference the taglib like this in your JSP:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
Share |
| Comment  | Tags