The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes mock exam questions 54 and 61 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 "mock exam questions 54 and 61" Watch "mock exam questions 54 and 61" New topic

mock exam questions 54 and 61

Kuppusamy Venkatasubramanian
Ranch Hand

Joined: Dec 30, 2004
Posts: 91

This is regarding the questions 54 and 63 in HFSJ mock exam.

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

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" %>

My answer was all(a,b,c,d) because in jsp 2.0 the uri is not the pointer to
the actual tld whereas the container loads all the tlds during startup and
during the tag call based on the action used with prefix the appropriate
tag class is called. But the answer given was C citing, it is the actual
localtion of the tld file. Which one is correct??

In question 63,

1) <%@ taglib uri="" prefix="mytags" %>
2) <mytags:foo bar="abc">
3) <mytags:forEach><mytags oSomething /></mytags:forEach>
4) <jsp:setProperty name="x" property="a" value="b" />
5) <c ut value="hello" />

Assuming the above lines are from a complete JSP, which lines will generate error.

My doubt is whether can we use reserved variables like forEach as taghandler
class calls. My answer was lines 3 and 4 will generate errors but according to
HFSJ, the answer is line 5 will only generate error..Any idea??

SCJP1.4, SCBCD 1.3, SCWCD 1.4, SCEA 5, JLPT-N3
My Blog
Sai Patnala
Ranch Hand

Joined: Jan 09, 2002
Posts: 60
Second question:
Unless it is a typo, second option does not have a closing tag or />. I would assume that would be error.
Third option is perfectly valid like infinite loop, probably causes runtime error depending on what the body of forEach tag is doing.
Last option is also syntactically valid.

Coming to taglib, uri part: J2EE Tutorial says, it has to start with /WEB-INF/<tldlocation>. You are right, uri in taglib is something that uniquely identifies the tag library.

Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026
Explanation given to question 54 would be correct if "uri" element was not declared in TLD.

If you have HFSJ refer last paragraph of page: 474

Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
Vishnu Prakash
Ranch Hand

Joined: Nov 15, 2004
Posts: 1026

Unless it is a typo,

Yes it is a typing error. Actually that was a self closing tag.

The reason line 5 produces error is
<c ut> is part of JSTL core Library which means you got to include a taglib directive in your jsp page.

Standard Syntax:
<%@ taglib prefix="c" uri="" %>

This is missing in that piece of code.
I agree. Here's the link:
subject: mock exam questions 54 and 61
It's not a secret anymore!