• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

include: question

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?..
 
Ranch Hand
Posts: 598
3
jQuery Google App Engine Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic