On 10/30/06, Wendy Smoak <[EMAIL PROTECTED]> wrote:

On 10/30/06, Rick Schumeyer <[EMAIL PROTECTED]> wrote:

> In any event, the author gives one method for including taglibs in jsp.
> For example, for tiles you would use:
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tilles" %>

This works, but requires you to put the tld files in your webapp under
WEB-INF.  With a Servlet 2.3/JSP 1.2 or later container, this isn't
necessary.

> But the current tiles docs say to use:
> <%@ taglib uri="http://struts.apache.org/tags-tiles"; prefix="tiles" %>
...
>    1. Is the only way to determine the correct uri value to look it up
>       in the docs?  (Is there any other way to know that the correct
>       value is "http://struts.apache.org/tags-tiles"; ?)

The final answer is in the tld itself, which you can find inside the
struts-tiles jar, or in svn:

http://svn.apache.org/repos/asf/struts/struts1/trunk/tiles/src/main/resources/META-INF/tld/struts-tiles.tld

The uri should match there in the tld and in your <%@ taglib > directive.

>    2. How does that really work ?  I know that nothing ever actually
>       connects to http://struts.apache.org, so how does that value get
>       mapped to the correct jar file under WEB-INF?  Are all the jar
>       files checked until one with a matching tag is found?

According to Craig, it's magic. :)
http://marc.theaimsgroup.com/?l=struts-user&m=104205482618830&w=2

I'm hazy on the specifics, but I think all the jars get scanned when
the webapp starts, and that it looks in META-INF and below.  Any tlds
it finds are then available to the webapp.


That is exactly right.  The important thing to realize is that the taglib
URI itself is just an arbitrary string ... the fact that most people make
them look like URLs was probably, in retrospect, a mistake.

The actual matching that occurs is the "uri" value you specify in a <%@
taglib %> directive, to the <uri> element in a TLD.  The two strings can be
anything at all, as long as they are identical.

--
Wendy


Craig

Reply via email to