• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do we need pageScope implicit object in EL?  RSS feed

 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have the pageContext object in EL, then what is the purpose having pageScope inplicit map there? Do I miss anything there? I'm confusing here.

Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The pageContext class exposes the environment in which the JSP is executing to the JSP. From it we can gather things like the request, response, and other contexts that are important to the page. Page scope, like request scope, sessions scope, and application scope is a place to store scoped variables.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The El implicit map object pageScope have the references to the attributes which were attached to the pageContext object. So, we can use pageContext object to get the attached attribute. Why do we need the pageScope map in EL?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2906
198
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abimaran,

Yes you can get to some of the properties of the pageContext implicit object in EL but not to the methods that accept parameters (so you can't get to the attributes).

Lets say you have a attribute set in your pageScope with the name "MyAttrib" that has a value of "MyAttribValue" you can't access it like this:

but with EL you can via the Map pageScope :


Regards,
Frits
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abimaran Kugathasan wrote:So, we can use pageContext object to get the attached attribute.

Ummm, no, we can't.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Ummm, no, we can't.

Yea, Let's have an example!
There is an attribute with name "foo" with the value of "bar". And here are the cases,
will return "bar" with
And, will return "bar "with
And, will return "bar" with

But, with the pageContext bean, if we try as,
Or, Or,
then it'll like,
. That means, it'll search for the property of the pageContext bean rather than attached object!

Correct?

Thanks!
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 2906
198
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Almost correct
are identical, but

will evaluate into

and that will be like

and that property doesn't exist on the bean pageContext

But you are getting it aren't you.

Regards,
Frits
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frits! And, one more query, If the jsp page is declared as an error page, then what about the exception which will be passed to this page? Is it passed it as an attached attribute of the pageContext or as a property of the pageContext bean? How can we access it with EL?

Thanks!
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, that's a property. I DO have to SearchFirst! Here is that.
BTW, there in no setException() method, then how can the container sets this exception to that page, if we've declared? Do I miss something?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
findAttribute() is a convenience method that searches all scopes for a particular scoped variable. It in no way means that pageScope is unnecessary -- pageScope is merely one of the scoped that findAttribute() searches.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:findAttribute() is a convenience method that searches all scopes for a particular scoped variable. It in no way means that pageScope is unnecessary -- pageScope is merely one of the scoped that findAttribute() searches.

I don't understand the purpose of this post! I'm searching for the answer, hoe the Container set the exception to the PageContect bean as the property without a setter?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's in answer to the earlier part of the topic. This is why it's a bad idea to start a new question in an existing topic rather than starting it in a new one. The replies get all intertwined.
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologies Sir, I thought, those are related topics, So I did!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!