aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Doubt on HFSJ Final Mock Exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt on HFSJ Final Mock Exam" Watch "Doubt on HFSJ Final Mock Exam" New topic
Author

Doubt on HFSJ Final Mock Exam

Xiaoxiao Lam
Greenhorn

Joined: Mar 04, 2006
Posts: 27
Hi,
I have doubts on the answer of Question #54 on page 827.

The Question and choices are:

Given a tag library descriptor located at /mywebapp/WEB-INF/tlds/mytags.tld, which would be the correct taglib directive? Assume mywebapp is the web application root and that there are no <taglib> tags in the deployment descriptor.

A. <%@ taglib uri="/mytags.tld" prefix="my" %>
B. <%@ taglib uri="/tlds/mytags.tld" prefix="my" %>
C. <%@ taglib uri="/WEB-INF/tlds/mytags.tld" prefix="my" %>
D. <%@ taglib uri="/mywebapp/WEB-INF/tlds/mytags.tld" prefix="my" %>

The answer given is C. But I think all of them are right. I think uri is only a name that matches the uri element declared in the tld file. So it can be any name. It doesn't need to be the location of the tld file. This is what I got when I read the book. Now I am confused. Please explain it to me if you can. Thank you so much.


SCJP 1.4<br />SCWCD 1.4
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

If no TLD is provided, the container will have to generate an implicit tag library.
The <path> element will be set relative to the root of the web application. Answer C is the only good answer as the container will generate a <path> set to "/WEB-INF/tlds/mytags.tld"

See the pec "JSP.8.4.3 Packaging Directly in a Web Application" for more details.


[My Blog]
All roads lead to JavaRanch
Xiaoxiao Lam
Greenhorn

Joined: Mar 04, 2006
Posts: 27
So, if there's a TLD file and the uri element value is not the path value (As I remember, we can make it whatever we like), we should make the uri attribute of taglib equal to the uri value declared in the TLD, right?

In this question, because it doesn't mention the uri element in TLD, we should select the best one which is the full path relative to the application root. Am I right? Thank you.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Sorry, I got confused with Tag Files. Please forget my first post.

The question is confusing indeed. Like you said, I would have thought that it depended on the uri set in mytags.tld.
Waiting for somebody to make this clear
[ March 13, 2006: Message edited by: Satou kurinosuke ]
MInu
Ranch Hand

Joined: Oct 09, 2003
Posts: 517
I think all of them are correct since the 'uri' element need not to be the exact path,it can be any name.
In the question it says that there are no <taglib> tags in the deployment descriptor.In jsp2.0 you dont have to
mention <taglib> in DD ie web.xml.The above four tablib directives will search for the corresponding 'uri' element in the mytags.tld file and invoke it.

This is what my understanding....can anyone clarify?
Thanks...
[ March 13, 2006: Message edited by: Vinod NS ]

God Gave Me Nothing I Wanted<br />He Gave Me Everything I Needed<br /> - Swami Vivekananda
Chandra Sagi
Ranch Hand

Joined: May 05, 2005
Posts: 162
Given a tag library descriptor located at /mywebapp/WEB-INF/tlds/mytags.tld, which would be the correct taglib directive? Assume mywebapp is the web application root and that there are no <taglib> tags in the deployment descriptor.


When you don't specify a <uri> inside the TLD, the Container will attempt to use the uri attribute in the taglib directive as a path to the actual TLD(pg 474 - last paragraph - HFSJ). In our case we haven't provided the <taglib> itself which has the <uri>, so the uri in the taglib directive which gives the correct path is the correct answer. In our case it is C.

Thanks
Chandu
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I still can't get it. I thought that :
there are no <taglib> tags in the deployment descriptor.
means that there is no taglib in web.xml. (under <jsp-config>)
So that does not prevent us from setting a uri in the TLD. All answers would be true then.
Xiaoxiao Lam
Greenhorn

Joined: Mar 04, 2006
Posts: 27
I think if the question asks for 1 answer, only C is right and if it asks for 4 answers, all are right. :-)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Yes
But don't worry, there will be no such confusion during the exam.
Chandra Sagi
Ranch Hand

Joined: May 05, 2005
Posts: 162
"/" in uri represents the location is from context root. So I don't think all the answers are correct. I was of the impression that <taglib-uri> tag exists only in <jsp-config> of DD and <name> tag in TLD. But I need to confirm it.

Thanks
Chandu
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Doubt on HFSJ Final Mock Exam