This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes include: question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "include: question" Watch "include: question" New topic
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?..
Bobby Sharma
Ranch Hand

Joined: Mar 18, 2008
Posts: 574
    
    1

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


Back to Java , again.
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: include: question