Greetings,
I found this mock exam question and do not understand the answer.
Can anyone help me understand? I've been staring at this for a while and just can't figure it out.
Question:
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
Possible answers:
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" />
Answer 2 is correct because the page attribute in the jsp:include action is interpreted relative to the current JSP page, that is coyote.jsp since detonate.jsp is included at translation-time of coyote.jsp. Therefore the dynamite.jsp located in the acme directory is required by coyote.jsp to display 'click'.
Answer 1 is incorrect because coyote.jsp would include the file dynamite.jsp from the same directory which would display 'boom!!!'. Answer 3 is incorrect because coyote.jsp would attempt to include dynamite.jsp from its parent directory which does not exist. Answer 4 is incorrect because jsp:include is incorrectly defined. The file atttribute is not supported by this action.
Thanks much.
Sincerely,
Jerry B.