• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include: question

 
Andriy Fedotov
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?..
 
Bobby Sharma
Ranch Hand
Posts: 598
3
Google App Engine jQuery Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic