File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ final mock exam question

 
valli kotari
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Divya Guttikonda
Ranch Hand
Posts: 47
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Radmika Arunachalam
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • 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.."
 
Mat Williams
Ranch Hand
Posts: 215
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Brad Howerter
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic