aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Regarding the URI element for Taglib Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Regarding the URI element for Taglib" Watch "Regarding the URI element for Taglib" New topic
Author

Regarding the URI element for Taglib

sravanthi pulukuri
Ranch Hand

Joined: Mar 15, 2007
Posts: 125
hi,

Iam very cofused with URL elemnt they use in Taglibe directive.

Is that the same one which we mention in web.xml or the one in TLD file??
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
sravanthi pulukuri wrote: hi,

Iam very cofused with URL elemnt they use in Taglibe directive.

Is that the same one which we mention in web.xml or the one in TLD file??



Please refer HFSJ and read the related chapters, you will get through with your doubts


Thanks <br />Poonam Agarwal SCWCD 86%
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Is that the same one which we mention in web.xml or the one in TLD file??

First, you don't need to declare tag libraries in web.xml, so you can forget about that

Think of URIs as being unique identifiers, to help the container locate them. The containers keeps a mapping of URIs to Tag Library, so when you use a URI in a tag directive, the container will use this mapping to locate the the library.


[My Blog]
All roads lead to JavaRanch
sravanthi pulukuri
Ranch Hand

Joined: Mar 15, 2007
Posts: 125
hi,

but then why is

<tag-lib>
<taglib-uri>
<taglib-location>

used in web.xml??

please help.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

but then why is

<tag-lib>
<taglib-uri>
<taglib-location>

used in web.xml??

It was used until Servlets 2.3. From Servlets 2.4, the container will look for mappings himself, so there's no need to use these tags anymore.
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
It was used until Servlets 2.3. From Servlets 2.4, the container will look for mappings himself, so there's no need to use these tags anymore.


yes Christophe is right. from servlet 2.4 the container autometically build the map between TLD and <uri> names. so when the jsp invokes a tag, container knows exactly where to find the TLD that describe the tag, by looking through a specific set of locations ehere TLDs are allowed to place in a web application.

But if you do specify an explicit <taglib-location> element in the web.xml , JSP 2.0 container will use it to create <uri>-to-TLD map.

So the container first look in the DD to check such mappings and after it choose to build automatic mappings. more important thing you do remember that theses tag are used only under <jsp-config> element.

like
sravanthi pulukuri
Ranch Hand

Joined: Mar 15, 2007
Posts: 125
hi,

that clears me.
Suppose if i dont specify explicity any mapping in web.xml so the URL element in TLD should be same as the one in Jsp invocation is it?

if it has a web.xml mapping how which URI should i map in jsp??
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
sravanthi pulukuri wrote:hi,

that clears me.
Suppose if i dont specify explicity any mapping in web.xml so the URL element in TLD should be same as the one in Jsp invocation is it?

if it has a web.xml mapping how which URI should i map in jsp??


I gave you an example in my last post. again this is the way to configure it

<jsp-config>
<taglib>
<taglib-uri>Someuri</taglib-uri> here you need to declared your URI or a name through which you can access this library in the JSP file
<taglib-location>/WEB_INF/someLocation</taglib-location>
here you have to declare the location reletive to the context path and its always starting with /WEB_INF
</taglib>
</jsp-config>


I hope this will help. Please refer HFSJ for further details
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Regarding the URI element for Taglib