• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

tag library deployed as .jar required web.xml mapping??

 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey ranchers,

please try to correct me if I am wrong. question from enthuware mock...

You have a JSP page that contains the following taglib directive for accessing tags of a tag library developed by ABC, Inc.:

<%@ taglib prefix="test" uri="http://abc.com/graphs/graphlib.jar">;

Further, the tag library is shipped to you in the form of a jar file named graphlib.jar.

You've kept this jar file in WEB-INF/lib directory of your web application.

Which of the following lines will you add in the deployment descriptor so that your jsp page can access the tags of the library?

1. <taglib>
<taglib-uri>http://abc.com/graphs/graphlib.jar</taglib-uri>;
<taglib-location>/lib/graphlib.jar</taglib-location>
</taglib>

2. <taglib>
<taglib-uri>http://abc.com/graphs/graphlib.jar</taglib-uri>;
</taglib>

3. <taglib>
<taglib-uri>http://abc.com/graphs/graphlib.jar</taglib-uri>;
<taglib-location>lib/graphlib.jar</taglib-location>
</taglib>


4. There is no need for a <taglib> element in web.xml, as the library will be downloaded from http://abc.com/graphs/graphlib.jar

5. None of these.

how option 3 would be the correct one.

1. when we specify uri attribute in the <taglib> directive it has the same value as <uri> tag in the TLD
OR
2. it has the same value as <taglib-uri> (sub-element of <taglib>)specified in the web.xml file.

according to me option 4 would be thw correct one, because when you place the tag library at the allowed location there is no need for explicit mapping in web.xml.
no matter even if the tag library placed in the form of .jar.

Please help me to get the correct one... got really confused. it seems my tag library knowledge vanishes


Thanks

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
even iam confused in the same way.let me wait for the replies.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
4 is not the answer either, because it says "as the library will be downloaded from http://abc.com/graphs/graphlib.jar". No, it's not going to be downloaded.

But I agree when you say that you don't need to declare the library in web.xml.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option 4 sould be like "There is no need for a <taglib> element in web.xml" indeed
 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
Correct me if iam wrong.

--->So there is no need for Taglib element in Web.xml

---->if it i snot present then value in taglib directive should be the uri declared in TLD file is it?

-----> suppose if the web.xml has taglib element then valu of uri element in taglib directive should be the one in web.xml

is it so?? please clarify iam always confused with this point.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Poonam Agarwal wrote:Option 4 sould be like "There is no need for a <taglib> element in web.xml"



Yes. But that's also possible according to JSP.7.3.6.1 of the Specification. Question is bit confusing as one could choose the option 5.

 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for Point 3 i had asked for:

in that case it ignores the uri name i give in in the TLD file??
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello sravanthi pulukuri,

--->So there is no need for Taglib element in Web.xml



yes there is no need to declare <taglib> element in the web.xml, as the jsp 2.0 container automaticaly searchs for the approriate one.

---->if it is not present then value in taglib directive should be the uri declared in TLD file is it?


right again!! if have to put the uri attrinute in the taglib directive to match the <uri> element mention in TLD


-----> suppose if the web.xml has taglib element then valu of uri element in taglib directive should be the one in web.xml



however JSP 2.0 container does the mapping automaticaly, you do not need to declare one in the web.xml. inspite of this container always look for the matching <taglib> element first indeed AND then it goes for the automatic mapping. So if you provide <taglib> element in web.xml file the uri attribute much match the one you specified with<taglib-uri> tag. though I am not much clear about it... Please verify this..


I hope this will help you






 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

thanks for the pateint reply.
so you mean it should match with the URI attribute to in taglib directive??


So if you provide <taglib> element in web.xml file the uri attribute much match the one you specified with<taglib-uri> tag


even iam not very clear. lets see if any one clears this confusion.
 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so you mean it should match with the URI attribute to in taglib directive??

Yes !!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic