File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

page vs. pageContext

 
Justin Rundle
Ranch Hand
Posts: 123
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vishal Chugh
Ranch Hand
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 836
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 123
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic