Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Poonam Agarwal
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
  • 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

 
sravanthi pulukuri
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
even iam confused in the same way.let me wait for the replies.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • Quote
  • Report post to moderator
so you mean it should match with the URI attribute to in taglib directive??

Yes !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic