The JSP specification defines the uri
attribute of the taglib
directive as:
Either an absolute URI or a relative URI specification that
uniquely identifies the tag library descriptor associated with
this prefix.
The URI is used to locate a description of the tag library as
indicated in Chapter JSP.7, “Tag Extensions”.
I'm not going to include any reference from "Chapter JSP.7" of the specification as the volume of information is large, but it basically says where to look for TLD files and how to match them based on the uri
value.
The server searches for TLD files inside your application (in predefined locations) and the uri
is only used to uniquely identify them. The server does not download the TLD file from the address of the uri
.
In fact the uri
is exactly that, a URI, so you can use something else than an address there (which is a URL), like for example an URN.
If for example you have a JSP like:
<%@ taglib prefix="p" uri="urn:isbn:0451450523" %>
<p:myTag/>
and you provide in your application (maybe inside WEB-INF) a TLD like:
<?xml version="1.0" encoding="UTF-8" ?>
<taglib xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
version="2.0">
<tlib-version>1.1</tlib-version>
<short-name>demo</short-name>
<uri>urn:isbn:0451450523</uri>
<tag>
<name>myTag</name>
<tag-class>test.pack.MyTag</tag-class>
<body-content>empty</body-content>
</tag>
</taglib>
then it should work.
Notice I use a URN like urn:isbn:0451450523
. It doesn't make sense to do that of course - since that particular URN identifies a book - but it should work.
And off course there are other reasons not to download the TLD from the uri
address, like making unnecessary traffic, your application will depend on an external server which might be down, or the application is internal and is denied access to the internet so there is no way to access the address... etc.