File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes page vs. pageContext 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 "page vs. pageContext" Watch "page vs. pageContext" New topic
Author

page vs. pageContext

Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

In the JSP technology model the page implicit object refers to the current servlet, how can I define what the pageContext implicit object refers to?
Vishal Chugh
Ranch Hand

Joined: Oct 27, 2007
Posts: 177
Hi Justin,

If we see the generated servlet code from HFSJ , we see ..

--> page is of type Object , it is having refrence of "this" object(that is current servlet instance) , which you also said , Please note "this" also come under implicit object catagroy , i learnt from mock.

--> pageContext variable (implicit variable) which is from PageContext class (an API given to us for convinience , specially in EL its very useful to get the request , exception objects etc.) is having refrence of PageContext object itself (which we got from factory method)
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Please note "this" also come under implicit object catagroy , i learnt from mock.
I don't know where you got that from, but there is no "this" implicit object. You might have your terminology confused.


Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
Vishal Chugh
Ranch Hand

Joined: Oct 27, 2007
Posts: 177
Hi,

I am doing enthuware mock exam these days , i came across question which asked me to choose " which of the following are implicit objects ?" : It answer included : this , page , application .

You are right , i attempted it wrong due to not choosing "this" as answer , then i thought may be i missed something useful while reading book ..

[I will paste the exact question once i reach home in 2-3 hours.sorry]

Thanks a lot...

Vishal Chugh
Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

hmmm... please do as I've yet to see an implicit object "this" but I have seen a question that has asked for which conditions will evaluate to true and the answers included: "this == page"
Charles Lyons
Author
Ranch Hand

Joined: Mar 27, 2003
Posts: 836
Was this in a JSP scripting element? In that case, it makes sense. "page" refers to the currently executing instance of the JSP page (which is compiled into a Servlet), but of course "this" also refers to that same instance. In fact, Tomcat does this in the generated Servlet:So "this == page" is always true. But we don't call "this" an implicit object.

I have never seen the point in "page"... Since it's an Object, you have to cast it to Servlet or JspPage or whatever when you want to use it. In contrast, "this" is ready to use right away!

With the transition to EL and it's implicit objects (which are different), all this JSP scripting element stuff becomes less important.
Vishal Chugh
Ranch Hand

Joined: Oct 27, 2007
Posts: 177
Hi,

The exact question was ( from Enthuware):

Which of the following are valid impilicit variables in JSP?

1) error 2)page 3)this 4)root 5)context

Answer : 2 and 3 .
[ December 18, 2008: Message edited by: Vishal Chugh ]
Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

I would have to question the integrity of those answers.

More so I'm interested if anyone else has seen come across this, as I would DEFINITELY answered only "page".
Vishal Chugh
Ranch Hand

Joined: Oct 27, 2007
Posts: 177
Additional:

The question was from objective-wise catagory : Under JSP chapter ( though it would have been randomly picked by engine).

I am also now worried about credibility of answers , its risky .
Justin Rundle
Ranch Hand

Joined: Mar 26, 2008
Posts: 123

Well... if you find out anymore info (like an errata or something), please post it here. For now I'm assuming that "this" is NOT considered to be an implicit object.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: page vs. pageContext