Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem Ques-From Mock Test

 
rashmi wadhera
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" />
 
Robert Miller
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 884
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Robert Miller
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked it out and the answer is indeed 2.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic