| Author |
tag library deployed as .jar required web.xml mapping??
|
Poonam Agarwal
Ranch Hand
Joined: May 12, 2008
Posts: 323
|
|
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
|
Thanks <br />Poonam Agarwal SCWCD 86%
|
 |
sravanthi pulukuri
Ranch Hand
Joined: Mar 15, 2007
Posts: 125
|
|
hi,
even iam confused in the same way.let me wait for the replies.
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14670
|
|
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.
|
[My Blog]
All roads lead to JavaRanch
|
 |
Poonam Agarwal
Ranch Hand
Joined: May 12, 2008
Posts: 323
|
|
Option 4 sould be like "There is no need for a <taglib> element in web.xml" indeed
|
 |
sravanthi pulukuri
Ranch Hand
Joined: Mar 15, 2007
Posts: 125
|
|
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
Joined: Mar 24, 2008
Posts: 3670
|
|
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.
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
sravanthi pulukuri
Ranch Hand
Joined: Mar 15, 2007
Posts: 125
|
|
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
Joined: May 12, 2008
Posts: 323
|
|
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
Joined: Mar 15, 2007
Posts: 125
|
|
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
Joined: May 12, 2008
Posts: 323
|
|
so you mean it should match with the URI attribute to in taglib directive??
Yes !!
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: tag library deployed as .jar required web.xml mapping??
|
|
|