Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implicit object "page"

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


page(Object) The instance if this page's implementation class. If the
scripting language is java (i.e. the page directive has the attribute
language="java"), this is equivalent to using the this keyword in scripting expressions.


I miss to understand the use of page implicit object and specially what
if we don't have page directive that has attribute language="java".

Any help please!

Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if we don't have page directive that has attribute language="java".

It's a bit of a mistery, as there's no other scripting language available yet ! Actually, "java" has become mandatory in the new JSP2.1 specification (the specification for SCWCD is 2.0). So don't worry much about that. Just remember that "page" works like "this".
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Christophe,

Does this mean, the above content was regarding specification 2.1?
And we have page implicit behavior as "this" without having page directive
with language attribute with "java" value.



Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does this mean, the above content was regarding specification 2.1?

No, sorry to confuse you. The above content is about 2.0. I wanted to say that you'll probably never see anything other than "java" as being the language used. So you can consider "page" to be "this".
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright!

As I understood, "java" is the only value for language attribute of the page
directive. But is it like, if we don't write <%@page language ="java"%> we
wont have access to page implicit object?


Thanks,
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. The default value is "java" so, it's ok if you don't set it in the page directive.
2. In JSP 2.0, the only defined and required scripting language value for this attribute is "java". So if you try to set it to something else, you'll probably get an exception from your container. I've never tried it.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But is it like, if we don't write <%@page language ="java"%> we
wont have access to page implicit object?


I dont think it will be that way chandra. Even if you miss out the language attribute, the page implicit object should be accessible.

As per the spec of JSP 2.0, (Section 1.10.1 The page Directive)

  • Only permissible value for the language is "java"
  • even if the language attribute to the "page" directive is missed out, its considered to have "java" - means, its the default value.
  • If any other non-java language attribute is used in the "page" directive, its a fatal error



  • As per the spec of JSP 2.0, (Section 1.8.3 Implicit Objects),
  • Variable Name : page
  • Variable Type : java.lang.Object
  • Semantic & Scope : The instance of this page's implementation class processing the current request page scope.


  • When the scripting language is java then page is a synonym for this in the body of the page


    With the above points, even if you dont specify any language for the page directive, as "java" is considered by default, you will definitely have access to the "page" implicit object.

    HtH.
     
    Chandra Bhatt
    Ranch Hand
    Posts: 1710
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Very Nice Raghavan!

    I got it very well.

    Thanks,
    [ July 20, 2007: Message edited by: Chandra Bhatt ]
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic