• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFSJ final mock exam question

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is a question from hfsj final mock exam

which jsp code would you use to include static content in a jsp?
a)<%@ include file="/segments/footer.html" %>
b)<jsp:forward page="/segments/footer.html" />
c)<jsp:include page="/segments/footer.html" />
d)RequestDispatcher dispatcher=request.getRequestDispatcher("/segments/footer.html");
dispatcher.include(request,response);

he gave the answers a and c.

but i thought its just a as he is asking about static content.

any help?
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I think both the answers are correct.By static content he dont mean at translation time or request time.Just the plain static html pages or something.If he say specifically request time or translation time then you have to go only for either include directive or jsp:include.Hope this clears ur doubt.Any corrections?

Thanks
Divya.
 
valli kotari
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

earlier i saw your post divya congrats for your score.

i am not clear about the above doubt.in page 450 of HFSJ he says....

a)include directive
<%@ include file="header.html" %>
STATIC:adds the content from file at translation time.

b)the <jsp:include> standard action
<jsp:include page="header.jsp" />
DYNAMIC:adds content at request time.

c)the <c:import> JSTL tag
<c:import url="...." />
DYNAMIC:adds content from url at request time

so i am not sure.
 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
For the same Question, Please can anyone tell me why option D is wrong? it is also one of the possible ways to include page right and also question didnt asks only "WHICH JSP CODE.." not "WHICH STANDARD ACTION.."
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Radmika,

You are right the question asks "WHICH JSP CODE..", because answer D does not have <% %> surounding it (ie its not a scriptlet) it is not valid in a jsp.

Technical, even pedantic I know.

HTH
Matthew
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, D is wrong, but what's wrong with B (which uses jsp:forward)? I just tried it and it works fine.

I guess it's how you interpret 'include'. When you forward to something, you include it's response, I say.
 
It looks like it's time for me to write you a reality check! Or maybe a tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic