1

Could any body verify this and if I am wrong any where then correct and/or elaborate further.

I believe a uri only uniquely identifies a tag library as it is specified in the <uri> element of a tld.

Like I have this one in a JSP

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Does anything similar to this (following) exists for the sake of SSL support?

<%@ taglib uri="https://java.sun.com/jsp/jstl/core" prefix="c"%>

Note: http v/s htpps

Kalher
  • 3,613
  • 2
  • 24
  • 34
  • Not sure why you want that? Any sane implementation will not go and fetch this URI anyway... – fge Jun 13 '13 at 22:34
  • Yes! I also think something similar, I asked this because somebody say so and which made me to think may be something which I don't know, so its just for verification, any way thanks. – Kalher Jun 13 '13 at 23:00

1 Answers1

1

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.

Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • So the answer is... No, the URI must be unique? Which is what the OP is asking. – Dave Newton Jun 16 '13 at 18:58
  • @DaveNewton: That's the question in the title, yes. But the description of the question and the comments seem to me that the OP is asking if it can access the taglib on HTTPS. Either way, the URI in the page must match an URI of a taglib. You can have the same taglib file with just the URI changed inside and you can refer to the same tags by different URIs. You can't off course use the same prefix inside the same JSP but you can use it across pages. And in this particular case (for JSTL) it would kinda suck to have to extract the TLDs from the JARs and manage them manually. So, unique is best. – Bogdan Jun 16 '13 at 19:39