| Author |
include: question
|
Andriy Fedotov
Ranch Hand
Joined: Mar 07, 2008
Posts: 49
|
|
HFSJ p. 430 question 12 QUESTION: How would you include dynamic content in a JSP, similar to a server-side include (SSI)? (Choose all that apply) A. <%@ include file="/segments/footer.jspf" %> B. <jsp:forward page="/segments/footer.jspf"/> C. <jsp:include page="/segments/footer.jspf"/> D. RequestDispatcher dispatcher = request.getRequestDispatcher("/segments/footer.jspf"); dispatcher.include(request, response); D (wrong): Option D would be correct if it was a scriplet: it functionality does the same thing as option C, but its syntax is only used in servlets. Does it mean that the only reason why option D isn't correct is that there're no <% %> around this code?..
|
 |
omi sharma
Ranch Hand
Joined: Mar 18, 2008
Posts: 489
|
|
Originally posted by Andrew Fedotov: HFSJ p. 430 question 12 D (wrong): Option D would be correct if it was a scriplet: it functionality does the same thing as option C, but its syntax is only used in servlets. Does it mean that the only reason why option D isn't correct is that there're no <% %> around this code?..
Option c is correct.D is certainly incorrect because RequestDispatcher sends request to other servlet or jsp file and I see no reason if you put scriplet then it will be correct and run like a charm. best regards, omi
|
SCJP, OCA 9i application developer, SCWCD 5.
When I was in hell someone told me to get heaven you need to do Java.
|
 |
Musab Al-Rawi
Ranch Hand
Joined: Aug 06, 2007
Posts: 231
|
|
I believe that Option D is correct if it was placed in <% %>. since the questions specifies that the code is to be placed in a JSP file then C is the correct answer. When it comes to implementation, at the end they are represented using RequestDispatcher. Musab
|
SCBCD - SCWCD - SCJD - SCJP - OCA
|
 |
 |
|
|
subject: include: question
|
|
|