• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

taglib descriptor questions?

 
Kevin Yun
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the tld file:
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>mt</short-name>
<uri>http://localhost:8080/servlet</uri>
<description>My first Tag library</description>
<tag>
<name>helloWorld</name>
<tag-class>HelloTag</tag-class>
<body-content>empty</body-content>
<description>A Hello World tag</description>
</tag>
</taglib>
Q:
1. uri: Based on my understanding, we can define our own uri. is that right?
2.tag-class. When we define the class, what is the default directory, is it in the WEB-INF\classes? I did put the HelloWorld class in that folder, but when I run a jsp test file, it seems can't find the class.
Eager to know the answer!
KY
 
shweta mathur
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)Yes, you can define anything for uri, but you can use this uri in your taglib directive, only if your tld file is present in a jar file in /WEB-INF/lib.
This is because JSP engine does the implicit mapping only when it finds the taglib.tld in a jar file.(In the META-INF folder)
2)Yes, by default the Tag Handler class file shud be in \WEB-INF\classes.
If you are not using a jar file, make sure the uri in the taglib directive of your JSP file is either the root relative path of the TLD or it is properly mapped in your web.xml.
[ March 06, 2003: Message edited by: shweta mathur ]
 
Kevin Yun
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Much appreciation to Shweta. Now let me make the question more specific:
web.xml:
<taglib>
<taglib-uri>mytags</taglib-uri>
<taglib-location>/WEB-INF/taglib.tld</taglib-location>
</taglib>
tld file is same folder as web.xml, the content is as above.
I put the HelloTag class under the WEB-INF\classes\
Here is the jsp directive:
<%@ taglib uri="mytags" prefix="mt" %>
and the jsp file is in the root folder.
Here is the test link: http://localhost:8080/hello.jsp
Any problems in this configuration?
Thanks!!
KY
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try to use complete class name include package name....
example :
<tag>
<name>helloWorld</name>
<tag-class>com.test.HelloTag</tag-class>
<body-content>empty</body-content>
<description>A Hello World tag</description>
</tag>
Correct me if i am wrong
daniel
 
Kevin Yun
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes!!! You are right, Daniel! It worked! Thanks for your help!
KY
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic