File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Exmulator mock exam question 36 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Exmulator mock exam question 36" Watch "Exmulator mock exam question 36" New topic
Author

Exmulator mock exam question 36

PRavi kumar
Ranch Hand

Joined: May 13, 2007
Posts: 69
Which of the following is a correct taglib declaration within a JSP page?

1)
<%@ taglib uri="WEB-INF/taglib.tld" prefix="h" %>
2)
<%@ taglib tagdir="/WEB-INF/tags/taglib.tld" prefix="h" %>
3)
<%@ taglib tagdir="/WEB-INF/lib/taglib.tld" prefix="h" %>
4)
<%@ taglib tagdir="/WEB-INF/tags/taglib.tld" prefix="jsp" %>

what is the correct answer.

the exam says 1,2 but i fell the anser is 1).

kindly clarify.
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Ravi,

Be cautious. with taglib attributes used in there

#1 can only be the answer.

One more thing
uri does not tell the path of tld in taglib;
its just mapping name. which should match with uri specified in tld thats it.


Thanks & Regards, T.Srinivasan
SCWCD 1.4(89%), SCJP 5.0(75%)
PRavi kumar
Ranch Hand

Joined: May 13, 2007
Posts: 69
Hi Thanks a lot,

Hi Marcus ,

can you correct this mock exam question in your site.
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
I don't like this question and I think I'll change it, but it is actually correct and it's worthwhile playing with the possibilities so you understand what is/might happen. I'll give a clue, I have just successfully used the code in a JSP as follows.

<%@ taglib tagdir="/WEB-INF/tags/taglib.tld" prefix="h" %>

<h:UsingTagDir/>

and got it to print out the text HelloWorld as a result of the tag UsingTagDir.

So, can anyone explain how I got that code to work (think laterally)...

Marcus


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
create a directory named "taglib.tld".
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
So answers 1 and 2 are correct?
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
No. Thats not convincing.

I will select only first option.

Second option didn't work out for me after creating "taglib.tld" directory and placing the tag file in there.

Marcus,
I feel these kind of extra stuff should not be placed in your mock tests.

people whoever take you exam, if they are given questions like this. definitely get confused.

So better categorize them separately for playing around.
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Srinivasan, what kind of problem did you get? I tried #2 and it worked for a tld with both a Simple and Classic tag. I did have to restart the server for it to work...
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
I think that it is a legitimate question. It illustrates that you can use uri and tagdir in the page directive. The real issue is why #3and #4 are incorrect.

1)
<%@ taglib uri="WEB-INF/taglib.tld" prefix="h" %>
2)
<%@ taglib tagdir="/WEB-INF/tags/taglib.tld" prefix="h" %>
3)
<%@ taglib tagdir="/WEB-INF/lib/taglib.tld" prefix="h" %>
4)
<%@ taglib tagdir="/WEB-INF/tags/taglib.tld" prefix="jsp" %>


Is it because
#3 - tld should not be under the lib directory
#4 - directive uses reserve work "jsp" in the value of prefix

What do you think?
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
Srinivasan is correct, it will work if you have a directory called taglib.tld, but I feel this is an unusual and misleading option that will not occur in the real exam.

Also JSP cannot be used as a prefix.
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Micheal,

I got you.

1. In tag directive if we use tagdir then our implemention class is tag file.
Here the path given for tagdir value, should locate the directory where in we place tag file. tag files can only be paced in tags directory or any sub-directory under tags.

2. In tag directive if we use uri then our implementation can be a SimpleTag our Custom Tag implementation. Here the uri, should match the uri specified in the tld file. and tld file can be placed in any sub-directory of WEB-INF.
[ August 11, 2007: Message edited by: Srinivasan thoyyeti ]
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
1. In tag directive if we use tagdir then our implemention class is tag file.
Here the path given for tagdir value, should locate the directory where in we place tag file.


Not necessarily. I thought the same thing before I tried it. I used the tagdir (#2) attribute of a page directive that pointed to a tld. In the tld I had implementations of both SimpleTag and Classic tags. It worked fine. I never tried to use the tagdir attribute to point to a tld but it works fine. So you can use the tagdir attribute to point to both a tagfile and a tld. I never thought of using the tagdir to point to a tld but it is legit to do so. Nice to know

PS - what about the option that has a tld under the lib directory? Is it incorrect because you should not place a tld under the lib (or classes) directory?
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Srinivasan, if you would like me to post all the artifacts involved in my reply, please let me know. I was just too lazy to do so without knowing that you were interested
Srinivasan thoyyeti
Ranch Hand

Joined: Feb 15, 2007
Posts: 557
Hi Michael,



Michael posted:
Not necessarily. I thought the same thing before I tried it. I used the tagdir (#2) attribute of a page directive that pointed to a tld. In the tld I had implementations of both SimpleTag and Classic tags. It worked fine. I never tried to use the tagdir attribute to point to a tld but it works fine. So you can use the tagdir attribute to point to both a tagfile and a tld. I never thought of using the tagdir to point to a tld but it is legit to do so. Nice to know


Its working fine. I am also happy to now that.

But i feel what is guaranteed to work by specification that only we can consider for exam and for real development.

What you say.


Micheal posted:
PS - what about the option that has a tld under the lib directory? Is it incorrect because you should not place a tld under the lib (or classes) directory?


As it was given in the book(as it follows specs), it should work.
let me try tomorrow.
What do you say for this ? did you try this scenario ?

Please respond quickly I have to take dinner! it 10:45 pm here in india.
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Sorry to keep you from your dinner.

Yes, it works under the lib directory, but I don't think that that is right. On the exam, they always make a point of saying where to put the tld's and it is not allowed under lib or classses (this is without the tagdir attribute). I wonder if using the tagdir attribute allows you to violate this standard?

I find this very interesting. I would like to continue later (tomorrow for you). Are you interested?

PS - enjoy your dinner
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exmulator mock exam question 36