• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Starting when tld files don't need to register in web.xml?

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was surprised to see I have to register tld files in web.xml when I'm using Tomcat 5.0. Isn't that the old way before JSP 2.0? I thought Tomcat 5.0 supports JSP 2.0 and doesn't need to register those tld files.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you don't really need. Where did you see this?
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made a custom tag handler and tld for it. I put the tld in /WEB-INF and then tried to access it in view.jsp this way:

<%@ taglib uri="/hello.tld" prefix="sample" %>

However, tomcat always tells me /hello.tld can't be found. After I registered tld in web.xml like this:

<taglib>
<taglib-uri>/hello.tld</taglib-uri>
<taglib-location>/WEB-INF/hello.tld</taglib-location>
</taglib>

Then I can access the tld.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Melo,

You are right. tomcat doesn't need tld registration. After I change this line in my view.jsp and I can access tld.

<%@ taglib uri="/WEB-INF/hello.tld" prefix="sample" %>

Thanks!
Jenny
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jenny,
if you put the "taglib" element in your dd, Tomcat will look for it. That's why it was not working, because you were missing the path. However, if you don't put it at all, Tomcat will find it by itsefl.
So, just try removing all the "taglib" element from your dd (this is actually old stuff from earlier versions of the spec). Tomcat will probably find it anyway.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Melo,

You are absolutely right. That's exactly what happened.

Thanks,
Jenny
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jiang,

Could you confirm that this line works...

<%@ taglib uri="hello.tld" prefix="sample" %>
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Should work, as long as you identify the uri of your tld as hello.tld.
And by the way, you don't need the extension .tld, this is not the name of the file. It's just a unique identifier.
[ July 30, 2005: Message edited by: Leandro Melo ]
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, I tried 'hello.tld' and it didn't work. Error says: File "/hello.tld" not found.
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jingh,

<%@ taglib uri="hello" prefix="sample" %>

I dont know why the previous one didn't work..but you can try without ".tld" extension.

Please do reply back!!!
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this:

<%@ taglib uri="hello" prefix="sample" %>

And I got error:

File "/hello" not found

Seems the only way to define tld in jsp directive without registeration in web.xml is this:

<%@ taglib uri="/WEB-INF/hello.tld" prefix="sample" %>

Thanks guys!
Jenny
 
kapil munjal
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Specifying the taglib directive
You need to specify the taglib directive in order to pick up the tags that you are going to put into the document. You specify the TLD file so that Page Designer can show you what tags are available in that TLD

Prerequisites:
Adding the Tag Library Descriptor (TLD) file.
Adding a taglib directive to a JSP file.
You can specify taglib directives in one of four ways:
Using the taglib-uri value in the Web deployment descriptor, as follows:
<%@ taglib uri="/yeartags" prefix="year" %>
<%@ taglib uri="http://www.mycorp/monthtags" prefix="month" %>
where both /yeartags and http://www.mycorp/monthtags are taglib-uri values that are defined in the Web deployment descriptor.
Using the context-relative path that refers directly to the TLD or JAR file, as follows:
<%@ taglib uri="/tlds/datetags.tld" prefix="date" %>
where /tlds/datetags.tld is a context-relative URI to the TLD file.
Using a page-relative path that refers directly to the TLD or JAR file, as follows:
<%@ taglib uri="../WEB-INF/tlds/hourtags.jar" prefix="hour" %>
where ../WEB-INF/tlds/hourtags.jar is a page-relative URI to the JAR file.
For a J2EE 1.3 Web project only, using the URI element value defined in the TLD, as follows:
<%@ taglib uri="http://www.mycorp/minutetags" prefix="minute" %>
where http://www.mycorp/minutetags is the URI element value that is defined in the TLD.
Tip: In a case where two or more TLDs are deployed inside a JAR file, you can use this format to specify each TLD.
Now that you have specified your taglib directive, you can add a custom tag to your JSP file. When you choose to insert a custom tag, Page Designer references the taglib directive and displays the tags from that custom library.



I found this content on this URL -
http://publib.boulder.ibm.com/infocenter/wsad512/index.jsp?topic=/com.ibm.etools.pagedesigner.doc/topics/tspectaglibdir.html
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following works


<%@ taglib uri="testEL.tld" prefix="classic" %>



Need to ensure that the "tld" file is in web application context root folder.

Env : Tomcat 5.0.30/Win XP.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PNS,

you are correct. if I put hello.tld under my app context dir, I can use

<%@ taglib uri="hello.tld" prefix="sample" %>

to access the tld. but we usually put tld under /WEB-INF, don't we?

Thanks for your input,
Jenny
 
PNS Subramanian
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes we do place it inside WEB-INF or a sub-directory within that. But then, we would have to specify that explicitly in the JSP file such as /WEB-INF/<tld dir> etc... That would set it right.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic