• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where is PAGE scope useful?

 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was debugging some code that looked like:


it fails with a The scope value PAGE is invalid

Its easy to change the ode to ScopedContext.REQUEST

but it raises a question, when is it useful or better to use ScopedContext.PAGE

Or is it just left over from long ago?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Outside of a JSP, the concept of page context does not exist, so you'd never use it in a servlet.

It's useful on a page for on-page variables (the current iteration of a forEach loop, for example) and for custom tags to comminucate with the page.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, since I live in servlets, its not useful for my contexts. Thanks for the explaination.
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Outside of a JSP, the concept of page context does not exist, so you'd never use it in a servlet.

It's useful on a page for on-page variables (the current iteration of a forEach loop, for example) and for custom tags to comminucate with the page.

I may have a misunderstanding about this. I thought you could set page-scoped variables in the view servlet, which then forwards to the view JSP which accesses those page-scoped variables.

Is that wrong?

Thanks Bear!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark E Hansen wrote:Is that wrong?

Yes. There is no way to bind a scoped variable to page context in a servlet. Request scope is where scoped variables are created to carry them to the forwarded JSP.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!