Meaningless Drivel is fun!
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
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: 596
    
    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


Most of the programming problems can't be solved because you don't know what the exact problem is.
Defining your problem correctly leads you to the right solution.
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
 
It's not a secret anymore!