If you want to use new features of JSP >= 2.1 and EL, like deferred binding (the #{…} construction in EL), you’ll find that you cannot achieve it within a Tag File with implicit TLD generation. It is simply because the implicit TLD defines that the Tag File is using JSPs in version 2.0.

How to solve it?

There are two possible solutions:

  • deliver an explicit TLD for your Tag Files,
  • modify the implicit TLD form.

Deliver an explicit TLD

This solution is an obvious one – when you define the TLD you can set the version attribute for <taglib> element which defines the JSP version. But defining an explicit TLD when you deploy your Tag Files directly into the web container seems to be a bit of a redundancy.

Modify the implicit TLD

This solution sounds more reasonable, but how to define the differences, when you don’t have an access to the container TLD template? Well, you can define a file named implicit.tld and put it in your Tag Files directory.

Why in the Tag Files directory?

If you take under consideration that the container is generating an implicit TLD and creates a tag library for each directory (and subdirectory) of a /WEB-INF/tags/, than you probably find it quite reasonable to put your own implicit.tld into the directory which reflects the library you want to affect.

Implicit.tld file

The point is that this implicit.tld file cannot have set anything more than:

  • the version attribute<taglib version="..."> (defines the JSP version used),
  • <taglib ...><tlib-version>,
  • <taglib ...><short-name>.

The <short-name> element is ignored by the web container.
If you put anything else – the container must throw an error. An example of such implicit.tld is as follows:

<taglib xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd"
   version="2.1">
    <tlib-version>1.0</tlib-version>
    <short-name>deferredTag</short-name>
</taglib>

The above example defines that all Tag Files within this library (this directory) will use a JSP 2.1.