This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In HFSJ PAGE 405,it says with the include directive,the source of included thing becomes PART of the page with the include directive I think it means that include directive can include dynamic page. But why the option A of question 12 of page 430 is wrong?
Well, the answer you are looking for is also on page 430 (look the note for Option A) where you have <%@ include ...> and not <jsp:include ...>.
SCJP, SCJD, SCWCD, SCBCD
Joined: Apr 27, 2004
Originally posted by avseq anthoy: In HFSJ PAGE 405,it says with the include directive,the source of included thing becomes PART of the page with the include directive I think it means that include directive can include dynamic page. But why the option A of question 12 of page 430 is wrong?
I think include directive means "<%@include ....%>",so I think the page 405 that says it can include dynamic page. Do I think wrong?
Joined: Aug 21, 2004
p. 430 Question 12 is not asking anything about include directive but only about dynamic content in a JSP. Hence the explanation why Answer C and not Answer A which is given on p. 430 is correct.
For those who don't have the HFSJ book I put the question here:
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);
Option A is incorrect because it uses an include directive, which is for static includes that happen at translation time.