aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes implicit object 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 "implicit object "page"" Watch "implicit object "page"" New topic
Author

implicit object "page"

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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,


cmbhatt
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

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".


[My Blog]
All roads lead to JavaRanch
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Feb 28, 2007
Posts: 1707
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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

Joined: Apr 20, 2006
Posts: 3355


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.


    Everything has got its own deadline including one's EGO!
    [CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
    Chandra Bhatt
    Ranch Hand

    Joined: Feb 28, 2007
    Posts: 1707
    Very Nice Raghavan!

    I got it very well.

    Thanks,
    [ July 20, 2007: Message edited by: Chandra Bhatt ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: implicit object "page"