• 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

no need for <taglib> tag in the web.xml

Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Complete the statement:

<taglib> element in the Web application deployment descriptor is used to...

1. specify a URI identifying a tag library.
2. specify the mapping of the name and the TLD file for a tag library.
3. specify the parameters needed by a tag library.
4. specify the TLD file location.
5. specify the mapping of TLD file and the library.

The correct answer is 2.
I have a doubt in the given explanation from enthuware. Please consider it:-

The <taglib> tag comes directly under the web-app element and it is used to specify the mapping between the name that will be used in the JSP pages and the URI where the actual tag library descriptor (.tld file) is located.

<!ELEMENT taglib (taglib-uri, taglib-location)>


<taglib-uri>/mylibrary</taglib-uri> ( You can use 'mylibrary' in the JSP taglib directive : <%@taglib uri="/mylibrary" prefix=="mylib"%> )
<taglib-location>/WEB-INF/tlds/MYLibrary.tld</taglib-location> // This is the location of tld file for the tag library.

This is a flexible way to specify the use of a tag library in a web application. Java classes implementing the tag library can be put into webapp in 2 ways:

1. Make a jar file of all the classes and include *.tld files in META-INF directory inside the jar. You can drop this jar file in WEB-INF/lib of the webapp.

In this case, you need not specify any <taglib> tag in the web.xml. The servlet container will automatically inspect the *.tld file in the jar file and for each <uri> element in the tld, it will add <taglib> (internally) tag in web.xml.

2. Keep un-jared classes in WEB-INF/classes. You can keep the *.tld at any place where the web application can access it but you have to specify that in the <taglib-location>. Eg. If you put mylib.tld in WEB-INF then you should give: <taglib-location>/WEB-INF/mylib.tld</taglib-uri>

As per my knowledge 2 point is not correct, as JSP 2.0 container automatically map uri-name and TLD by looking the .TLD files at the allowed location.

you not reuire to get the explicit mapping in web.xml file. Am i correct??

Please provide your feedback

Posts: 14691
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please quote your sources.
Ranch Hand
Posts: 31
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Poonam,

From JSP 2.0 you don't need to put <taglib> in the DD. You need to keep the TLD files in correct place.
But this tag is used to maintain compatibility.
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello Christophe,
This question from Enthuware Mock. please provide your input.
This is my favorite tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic