• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCWCD@WHiz Include question confusion

 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again-
SCWCD@WHIZ has the following 'include' question:
The answer says it's d but c works just as well when I run it on JRun...
Max

A website is developed using JSP's and Servlets. Every page of the site needs to have copyright statement at the bottom of the page. Considering the code below (TestPage.jsp and copyright.html), choose the valid options to be used at //XXX position to include the copyright statement as the last statement of the JSP page.
// TestPage.jsp
<HTML>
<HEAD>
<TITLE> My Test Page </TITLE>
</HEAD>
<BODY>
// lot of html code describing my page
//XXX
</BODY>
</HTML>
//copyright.html
<HTML>
<BODY>
Copyright � XYZ Pvt Ltd.
</BODY>
</HTML>
Answers:
a)
<jsp:include page="copyright.html" >
</jsp:include>
b)
<% include file="copyright.html" flush="false" %>
c)
<%@ include file="copyright.html" flush="true" %>
d)
<jsp:include page="copyright.html" flush="true" />
e)
None of the above
 
Peter Masreblta
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The syntax for include directive is:
<%@ include file="relativeURL" %>
Tomcat will give "Include directive: Invalid attribute, flush" error if 'flush="true"' would be included in include directive.
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer is d) <jsp:include page="urlSpec" flush="true"/>
Pages can also be included by using include directive whose syntax is <%@ include file=" relativeURLspec" %> option c) has extra attribute flush="true"
So the only possible answer is D)
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A) is also a correct answer. Any JSP tag can be written as a <start tag> <end tag>. Writing it as <jsp:include page="copyright.html"/> is the short cut. In the jsp:include tag, flush is optional with a default of false. If you try and use it with JSP 1.1 you will get an exception because flush="false" isn't supported however, in JSP 1.2 the support is provided so....
------------------
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C) is incorrect because the <%@ include> directive doesn't allow attributes.
------------------
I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
 
sridhar satuloori
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carl,
JSP1.1 spec clearly says that you have to use flush="true". flush="false" or no flush attribute (as flush is a mandatory attribute) is a syntax error.
In JSP1.2 it is mentioned that flush can take either true or false and is an optional.
I have a questions
1) are we answering against JSP1.1 or 1.2?
if it is against 1.1 then A) is wrong
Sridhar

 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exam and objectives are based on Servlet 2.3 and JSP 1.2 so, A is correct.
 
Win Yu
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so the answer shoulcd be a) and d), am I right?
Another question,<jsp:directive.include> is difference from <jsp:include>, right?
we can use <%@include> in our jsp page. where we use <jsp:directive.include>? in XML?

[This message has been edited by Win Yu (edited November 07, 2001).]
 
Max Tomlinson
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, so it does on Tomcat 4.0. That's what I get for using JRun (Servlet 2.2, JSP 1.1).
thanks!
max
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic