Identifying the Tag Library in a JSP Page
To identify the library in JSP pages, you use a
taglib directive
like this:
<%@ taglib prefix="ora" uri="orataglib" %>
The container uses the uri attribute value to
locate the TLD file for the tag library. The value must be either a
symbolic name or a file path. A symbolic name is any string that is
unique in the application. An HTTP URL is often used to be reasonably
sure that it’s unique in any application. Even when
an HTTP URL is used, the container uses it only as a symbolic name;
it does not try to get the resource specified by the URL.
If the uri value is a symbolic name, it must be
mapped to the actual location of the TLD file somehow. In JSP 1.2, a
new auto-discovery mechanism was introduced to make this very easy.
Here’s how it works. The TLD includes a
<uri> element to define the default URI for
the library:
<taglib> ... <uri>orataglib</uri> ... </taglib>
When the web application is started, the container scans through the
WEB-INF directory structure for files with
.tld extensions and all JAR files containing
files with .tld extensions in their
META-INF directory. In other words, locating all
TLD files. For each TLD, the container looks for the
<uri> element and creates a map from the URI
to the TLD that contains it. In your JSP page, you just have to place
a taglib directive with a uri
attribute value matching the URI in the TLD.
Prior to JSP 1.2, you had to define the mapping manually in the deployment descriptor for the application ...
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