aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes mock question-page directive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "mock question-page directive" Watch "mock question-page directive" New topic
Author

mock question-page directive

Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
Hi All,
Please have a look at this question:

Is the following JSP code legal? Select the one correct statement.
<%@page info="test page" session="false"%>
<%@page session="false"%>

A) Yes. This is legal JSP syntax.
B) No. This code will generate syntax errors

My answer is A. But they have stated correct answer as B.
What will be your answer?


Thanks,<br />-Rancy
Mohit Chadha
Ranch Hand

Joined: Feb 04, 2007
Posts: 264
The following is from the specifications:
There shall be only one occurrence of any attribute/value pair defined by this directive in a given translation unit, unless the values for the duplicate attributes are identical for all occurrences. The import and pageEncoding attributes are exempt from this rule and can appear multiple times.

Hence according to the specifications it should be A.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9525
    
    2

Mohit,

The answer should be B. Only the import attribute can appear any number of times in a jsp page.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Tim Storms
Ranch Hand

Joined: Apr 27, 2006
Posts: 64
I don't agree. When an attribute occurs more than once, it doesn't give an error when its value is the same. The import and pageEncoding attributes may occur multiple times.

The answer is A in my opinion.


SCJP 1.5, SCWCD 1.4, SCBCD 5
Rancy Chadha
Ranch Hand

Joined: Jul 12, 2006
Posts: 135
All of you thank you very much for your replies
Kosala W.Abayagunawardene
Ranch Hand

Joined: Dec 15, 2007
Posts: 47

Tim Storms wrote:I don't agree. When an attribute occurs more than once, it doesn't give an error when its value is the same. The import and pageEncoding attributes may occur multiple times.

The answer is A in my opinion.




Page directive is used to specify a number of page specific attributes
such as content type, page encoding, classes to import and buffering
model etc. A translation unit can contain more than one instance of
page directive, in any order, anywhere and all attributes will be
applied together to the whole translation unit. However there are
few exceptions.

1. pageEncoding and contentType attributes must appear at the
beginning of the page.
2. An attribute must appear only once in a translation unit unless
the values of the attribute are same for all occurrences,
otherwise a translation error will occur. The import and
pageEncoding can appear more than once in a translation unit.
3. pageEncoding attribute can appear at most once per a file
otherwise a translation error will occur.

Note: A JSP source file and any other files included with include
directive is called the translation unit.


[SCJP] ::[SCWCD]::[BCS::BIT::SCBCD] - Studying[My Blog]
Hasnain Javed Khan
Ranch Hand

Joined: Nov 23, 2007
Posts: 73
2. An attribute must appear only once in a translation unit unless
the values of the attribute are same for all occurrences,
otherwise a translation error will occur. The import and
pageEncoding can appear more than once in a translation unit.

Note: A JSP source file and any other files included with include
directive is called the translation unit.


So it means in



And in


would cause an error ?

Kind Regards.
Hasnain.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Hi guys,
Next time, try not to wake up zombies Thank you.


[My Blog]
All roads lead to JavaRanch
 
Consider Paul's rocket mass heater.
 
subject: mock question-page directive