• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Why do we need pageScope implicit object in EL?

 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Creator of Enthuware JWS+ V6
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3411
320
Android Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies Sir, I thought, those are related topics, So I did!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic