jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Custom tags in Tomcat 3.1 - what's the function of the URI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Custom tags in Tomcat 3.1 - what Watch "Custom tags in Tomcat 3.1 - what New topic
Author

Custom tags in Tomcat 3.1 - what's the function of the URI

Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

In Tomcat, there's 2 places that you'll have to specify a uri.
(1) WEB-INF/tlds/yourfilename.tld
(2) WEB-INF/web.xml
In (1) the file looks like this (abridged for brevity):
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>Time of Day</shortname>
<uri>http://raverun.com/taglib</uri>
<info>A simple tag library to print time of day</info>
<tag>
<name>tod</name>
<tagclass>TodTag</tagclass>
<info>Prints petang or pagi</info>
</tag>
</taglib>
In (2), it looks like this:
<web-app>
<taglib>
<taglib-uri>
http://raverun.com/taglib
</taglib-uri>
<taglib-location>
/WEB-INF/gavin/gavin.tld
</taglib-location>
</taglib>
</web-app>
My question: Is the <uri> & <taglib-uri> intrepreted for any reasons other than for namespaces purposes?
How are they related ?
Thanks
Photek

Regards,

Pho
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
Both uri indicate where your tag definitions will be. You could write your own customerized tag and place a .tld file that somewhat like this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>2.2</tlibversion>
<jspversion>1.1</jspversion>
<shortname></shortname>
<info>info>
<tag>
<name></name>
<tagclass></tagclass>
<teiclass></teiclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name></name>
<required></required>
<rtexprvalue></rtexprvalue>
</attribute>
</tag>
</taglib>
and change that uri point to this file.
Hope this answers your question.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
The primary purpose of a URI is unique identification.
For example, here is the start of the taglib for the examples in my book:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<!-- a tag library descriptor for JSPbook Chapter 11 examples -->
<taglib>
<!-- after this the default space is
"http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd"
-->
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>JSPbook</shortname>
<uri>JSPbook/taglib</uri>
<info>
A simple tab library for the JSP and Servlets book examples
</info>
Note that the uri does not give any location.
In the JSP the tag:
<%@ taglib uri="JSPbook/taglib" prefix="ch11" %>
tells the JSP engine to use that taglib where the prefix ch11 appears.
Bill

 
Don't get me started about those stupid light bulbs.
 
subject: Custom tags in Tomcat 3.1 - what's the function of the URI
 
Similar Threads
Custom Tags
Problem with Custom Tags
Custom Tag NOT Compiling
CUSTOM TAG NOT WORKING
Error When starting Tomcat server