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)
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"
Joined: Mar 27, 2003
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.
Joined: Oct 27, 2007
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 ]