• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

mock question-page directive

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mohit,

The answer should be B. Only the import attribute can appear any number of times in a jsp page.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancy Chadha
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All of you thank you very much for your replies
 
Ranch Hand
Posts: 47
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
Next time, try not to wake up zombies Thank you.
 
Oh. Hi guys! Look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic