You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rick Schumeyer <rs...@ieee.org> on 2006/10/31 02:47:07 UTC

taglib uri question

I'm coming up to speed on struts 1.3.5, and I will be asking some 
possibly silly questions soon.

I have been reading the "Jakarta Struts" book by Cavaness (2nd ed) which 
covers struts 1.1.  I get the impression that there were several 
significant changes from 1.0 to 1.1; I'm not sure how big the changes 
are from 1.1 to 1.3.

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" %>

But the current tiles docs say to use:
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

My questions are:

   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" ?)
   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?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: taglib uri question

Posted by Craig McClanahan <cr...@apache.org>.
On 10/30/06, Wendy Smoak <ws...@gmail.com> wrote:
>
> On 10/30/06, Rick Schumeyer <rs...@ieee.org> 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

Re: taglib uri question

Posted by Wendy Smoak <ws...@gmail.com>.
On 10/30/06, Rick Schumeyer <rs...@ieee.org> 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.

-- 
Wendy

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org