-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Joseph,

On 10/26/2009 12:15 PM, Joseph Morgan wrote:
> Well, I'm trying to contain common tag libraries in a single, common,
> easily deployable space so I only have to deploy them once for all
> apps, and not into every app in existence (though there are arguments
> to be made for each app having its own independent stuff, even if it
> is the exact same stuff).
> 
> That path <taglib-location>/lib/tld/c.tld</taglib-location> works
> just fine with the JSTL tags, but not my custom tags.  It is easy
> enough to put my TLD declaration in the META-INF/web.xml.  It is now
> becoming a matter of "wtf"....

I suspect that Tomcat treats the JSTL declaration specially based upon
its taglib-uri: they don't want you to break the JSTL by incorrectly
specifying its location, so they ignore your taglib-location.

Try this: set the taglib-location to something that is obviously wrong
like /does-not-exist or something. If it works, you can convince
yourself that some trickery is being performed by Tomcat for the
standard libraries. This same technique is used with XML schemas for
things like webapp deployment descriptors so that Internet access is not
required to verify web.xml and other documents (not to mention avoiding
the the roundtrip time to fetch the schema or DTD, etc.).

> However, my Tomcat is not responding as you suggest.  The Tag libs
> are not relative to the JSP, but to the context root, always.  That
> is, at my context root, I have my JSP:

[snip]

> Note the taglib references are identical between the two.
> 
> The CORE jstl tags are (now) referenced in my
> {catalinahome}/conf/web.xml as:
> 
> =================================== <taglib> 
> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> 
> <taglib-location>/lib/tld/c.tld</taglib-location> </taglib> 
> ===================================
> 
> And my custom tags are in my {contextRoot}/META-INF/web.xml as:
> 
> =================================== <taglib> 
> <taglib-uri>customTags</taglib-uri> 
> <taglib-location>/../../lib/tld/custom.tld</taglib-location> 
> </taglib> ===================================
> 
> And BOTH work for BOTH the JSPs regardless of their location relative
> to the context root.

Interesting. Tomcat must be doing a "you know what I mean" resolution of
the resource based upon the fact that the definition is being provided
in conf/web.xml for the server instead of WEB-INF/web.xml for your
webapp (right?).

> However, if I simply move the custom tag
> reference from the {contextRoot}/META-INF/web.xml into the
> {catalinahome}/conf/web.xml, the custom tags stop working.

Oh, so I have it exactly wrong: it works when specified in your webapp's
web.xml but not in Tomcat's web.xml. Hmm. Try using
"/lib/tld/custom.tld" in conf/web.xml and see what happens?

> It is as
> if JSTL is built into Tomcat...  Because the JSTL stuff seems to be
> able to be referenced either way; by my ugly relative path and by the
> cleaner "/lib/tld/c.tld" version.  However, my custom tags ONLY work
> when referenced within the {contextRoot}/META-INF/web.xml with
> "/../../lib/tld/custom.tld"

Sounds like you've got your solution, even if it's non-ideal for you. I
would still highly recommend that anything not explicitly provided by
the server (such as JSTL) be included in your webapp if your webapp
needs it. Then you don't have to play games like this.

Good luck,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkrlz1AACgkQ9CaO5/Lv0PCrPQCffNwVULkTdAu5GrPwcQ4fYPZ6
trAAoLLc1R4MrsI6iY/6isQymiVTb0zJ
=7MwL
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to