This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFSJ final mock exam question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFSJ final mock exam question" Watch "HFSJ final mock exam question" New topic
Author

HFSJ final mock exam question

valli kotari
Greenhorn

Joined: Jul 08, 2005
Posts: 4
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

Joined: Mar 09, 2005
Posts: 47
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

Joined: Jul 08, 2005
Posts: 4
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

Joined: Mar 29, 2004
Posts: 45
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

Joined: Jul 20, 2005
Posts: 215
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

Joined: Jan 06, 2006
Posts: 4
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HFSJ final mock exam question
 
Similar Threads
Doubt in Final Mock Exam:HFSJ
including static content, mock exam question
HFS Mack Exam Q22 - Page 772 - ResquestDispatcher - Is the answer correct?
Doubt on HFSJ Final Mock Exam #22
HF final mock exam Q22