wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem Ques-From Mock Test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem Ques-From Mock Test" Watch "Problem Ques-From Mock Test" New topic
Author

Problem Ques-From Mock Test

rashmi wadhera
Ranch Hand

Joined: Apr 06, 2004
Posts: 44
Does anyone know the METHOD for solving these kind of problems.


Given four JSP files arranged in the following directory hierarchy, identify the correct action that should be defined in acme/detonate.jsp to display 'click' when coyote.jsp is requested.

coyote.jsp
dynamite.jsp
acme/detonate.jsp
acme/dynamite.jsp
coyote.jsp contains <%@ include file="acme/detonate.jsp %>
dynamite.jsp contains boom!!!
acme/dynamite.jsp contains click

1 <jsp:include page="dynamite.jsp"/>
2 <jsp:include page="acme/dynamite.jsp"/>
3 <jsp:include page="../dynamite.jsp"/>
4 <jsp:include file="dynamite.jsp" />


SCJP1.4, SCWCD1.4 (preparing)
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I'm just preparing for this exam myself, so I'll give it a try.

The question comes down to how do you include acme/dynamite.jsp from acme/detonate.jsp. You could use either the include directive or the include action. Without knowning more about the files involved you cannot say whether either one is appropriate or not, but all of the choices you are given specify the include action, so it doesn't matter.

Now look at the four choices. The jsp:include action takes a page attribute, not a file attribute, so choice 4 is out. The remaining three choices are different only in the path structure of the page attribute. Choice 3 cannot possibly reference acme/dynamite.jsp, and we don't know enough about /dynamite.jsp to know whether it includes the necessary file. Now I have to guess. Since none of the page attributes begin with a '/', I assume they are all relative to the current page. Therefore I guess the answer is 1.

Now excuse me while I look it up.

Robert


Originally posted by rashmi wadhera:
Does anyone know the METHOD for solving these kind of problems.


Given four JSP files arranged in the following directory hierarchy, identify the correct action that should be defined in acme/detonate.jsp to display 'click' when coyote.jsp is requested.

coyote.jsp
dynamite.jsp
acme/detonate.jsp
acme/dynamite.jsp
coyote.jsp contains <%@ include file="acme/detonate.jsp %>
dynamite.jsp contains boom!!!
acme/dynamite.jsp contains click

1 <jsp:include page="dynamite.jsp"/>
2 <jsp:include page="acme/dynamite.jsp"/>
3 <jsp:include page="../dynamite.jsp"/>
4 <jsp:include file="dynamite.jsp" />
DM
Ranch Hand

Joined: May 10, 2004
Posts: 31
IMO, the answer should be 2 (assuming there is a typo in coyote.jsp, the file attribute is not enclosed in "").

My mehtod is : acme/detonate.jsp is included statically, so it becomes part of coyote.jsp (or its servlet, rather) at page-translation time. coyote.jsp is at the root dir, so it should use <jsp:include page="acme/dynamite.jsp"/>

Worth trying it out in tomcat.

-Durgesh
SCJP 1.4, SCWCD 1.4, SCDJWS(beta)
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
Durgesh,

Good point about the JSP being statically included from a higher directory. You may be right. When I get the opportunity I'll try it out and see what happens.

Robert


Originally posted by durgesh mankekar:
IMO, the answer should be 2 (assuming there is a typo in coyote.jsp, the file attribute is not enclosed in "").

My mehtod is : acme/detonate.jsp is included statically, so it becomes part of coyote.jsp (or its servlet, rather) at page-translation time. coyote.jsp is at the root dir, so it should use <jsp:include page="acme/dynamite.jsp"/>

Worth trying it out in tomcat.

-Durgesh
SCJP 1.4, SCWCD 1.4, SCDJWS(beta)
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Yep, I agree with the answer being 2. There is an example to illustrate this in the JSP 2.0 Specification @ page 1-109 to 1-110.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Robert Miller
Ranch Hand

Joined: Jun 18, 2004
Posts: 56
I checked it out and the answer is indeed 2.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem Ques-From Mock Test