File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

uri element ,taglib element

 
shanthisri mocherla
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,

I've questions regarding <uri> element and <taglib> element in TLD.
1. How many <uri> elements we can have in a TLD.(i think it is only one).Is it correct???
2.How many <taglib> elements we can have in a TLD?(i think this is also one).
Am i correct?

Thanks in advance
Shanthi
 
Sai Patnala
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
taglib is only once and is mandatory element. Mandatory sub elements of taglib are tlib-version and, short-name.
uri is optional and if appears only once.
tag sub element is 0 or more, so is listener & tag-file.
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai
How come uri element is optional? we have to match the uri attribute in taglib directive of JSP to the uri element of TLD.right???
And also how do we declare tag files in TLD???


thanks
Shanthi
[ December 01, 2005: Message edited by: shanthisri mocherla ]
 
Sai Patnala
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP Specification Page 400. TLD section.

You are right, uri is mandatory as attribute to taglib but not in the TLD file.

I hope i did not confuse you!
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even if you don't specify uri element in TLD you can use other ways to locate the TLD file.

You can use <jsp-config> element in DD, like

<jsp-config>
<taglib>
<taglib-uri>
<taglib-location>
<taglib>
<jsp-config>

to locate the TLD file. You can even use the uri attribute in the taglib directive to locate the path of the TLD file, but it is considered a bad practice.
[ December 02, 2005: Message edited by: Vishnu Prakash ]
 
Prathibha Bharathi Alam
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Sai,
uri attribute of taglib directive is not mandatory ,I think.
We can tagdir (incase of tagfiles) instead.

Regards,
Prathibha.
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vishnu Prakash,
Thanks for your reply.
But <jsp-config><taglib> is not used in mapping taglib uri to a TLD file in current JSP 2.0 spec. I think.
What do you say??

And uri is just a made-up name Right??So how do you map a uri to a TLD file???
thanks for your response

shanthi
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got to understand the basic need of uri. It is just a name thats used to map(link) the jsp page's Tags with JSTL(or)Custom handlers that are defined in the TLD file. For example if the page is request by the user and when the container comes across the tags in that page where will it find the code that implements the tags functionality. All this definition is done in TLD file(About the tag handler class thats invoked, its name, attributes, whether it is allowed to have body-content) But there has to be something that maps(links) the JSP Page to the TLD file. And that process is carried out by the uri.

The usual way of mapping a jsp page to a TLD would be having a uri attribute that holds the same value that of uri element in the TLD. But uri element in TLD file is optional which brings us a interesting question which you had asked in your second post in this thread.

Now proceed with my reply. <jsp-config> element is defined in DD. In that way you can locate the TLD file.
In <taglib-uri> you specify the uri name and with <taglib-location> you specify the actual location of the TLD file.

For example
<jsp-config>
<taglib>
<taglib-uri>MyURI</taglib-uri>
<taglib-location>/WEB-INF/MyTldFile.tld</taglib-location>
</taglib>
</jsp-config>

You can even use the uri attribute in the taglib directive to locate the path of the TLD file, but it is considered a bad practice.

By this I mean you can do something like

<% @taglib prefix="mine" uri="/WEB-INF/MyTldFile.tld" %>

Which will help the container to locate the TLD file in your directory structure.

Note: Your TLD file can live in(or) exist in four place/location of your webapp structure.

[ December 02, 2005: Message edited by: Vishnu Prakash ]
[ December 02, 2005: Message edited by: Vishnu Prakash ]
 
Vishnu Prakash
Ranch Hand
Posts: 1026
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

And also how do we declare tag files in TLD???


<% @taglib prefix="mine" tagdir="/WEB-INF/MyTagFiles" %>

To include tag files in JSP we use "tagdir" attribute
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic