Timothy Stone, MIT, SCJP
http://www.petmystone.com/
"This Satan's drink [coffee] is so delicious, we shall cheat Satan and baptize it." --Pope Clement the VIII (1592-1605)
Timothy Stone wrote:Regarding HFS&JSP 2nd Ed. page 426, question 12.
I have looked at some of the answers from c. 2007, but nothing directly asking the question, Why is Answer C more correct than Answer A.
Sure the comments on the answer provide some context to the author's thinking, but I have used "SSI" in Apache and Tomcat, and the include standard action and the directive provide SSI-like functionality as I have used SSI in the past. Is it the "dynamic content" phrasing that makes C more correct than A?
The question is provided below for context.
Thanks!
Tim
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);
Since the include directive (which is static) happens at the JSP translation time and the include standard action (which is dynamic) occurs at runtime, standard action is the better / correct answer in this case.How would you include dynamic content in a JSP, similar to a
server-side include (SSI)? (Choose all that apply.)
SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3,OCJP8 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
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);
DIRECTIVE:
include
PARAMETER:
file, direct or virtual
DESCRIPTION:
This is probably the most used SSI directive, allowing the content of one document to be included in another. The file or virtual parameters specify the file (HTML page, text file, script, etc) to be included. The file parameter defines the included file as relative to the document path; the virtual parameter defines the included file as relative to the document root.
Is it the "dynamic content" phrasing that makes C more correct than A?
A JSP container can include a mechanism for being notified if an included file changes, so the container can recompile the JSP page. However, the JSP 2.0 specification does not have a way of directing the JSP container that included files have changed.
An include directive regards a resource like a JSP page as a static object; i.e. the text in the JSP page is included. An include action regards a resource like a JSP page as a dynamic object; i.e. the request is sent to that object and the result of processing it is included.
SCJP 5, SCWCD 5
SCJP 6 [SCJP - Old is Gold]
http://localhost:8080/myApp/test.jsp?test=Howdy%20Rachners
Including static file: The Request parameter 'test' is equal to: Howdy Rachners. End of static included file. After inclusion.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |