This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HFSJ Mock Exam

 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which jsp code would you use to include a static content in a jsp?

1. <%@ include file ="/footer.html" %>
2. <jsp:include page="/footer.html/>

Both 1 & 2 are correct. I think option 2 is for dynamic content. So option 2 should be wrong answer right?

Srividhya
 
Paul Brabban
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I think it is that the include directive pastes in the source of the included file at translation time (very static) whereas the <jsp:include> action makes a runtime call to the included resource, picking up any dynamic content but at a performance penalty.

You could use either, but I guess you would use the include directive for better performance if you knew the included content would not change.

Cheers,

Paul
 
Srividhya Kiran
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Paul even I know the reason but since it was given static inclusion I thought <%@ include> is more appropriate.
 
deepa raj
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
footer page is html not jsp. mostly html will have only static contents.

so both the answers are correct.
 
prasanna perumal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Srividhya Kiran:
which jsp code would you use to include a static content in a jsp?

1. <%@ include file ="/footer.html" %>
2. <jsp:include page="/footer.html/>

Both 1 & 2 are correct. I think option 2 is for dynamic content. So option 2 should be wrong answer right?

Srividhya


Since the file to be included in both the cases are html, option 1 and 2 are correct. Because in html there is no dynamic content.
[ August 11, 2008: Message edited by: prasanna perumal ]
 
Baddy Davay
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per the Rule
include directive- Support static at translation time
include action - Supports static and dynamic content at runtime.
So you can use both.They did not ask you as performance wise ,which one you would use. So you can mark both as correct.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!