Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

c:forEach  RSS feed

 
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz....could anyone figure this out?

Consider the following code snippet:-



We're doin' nothin' special here but looping over the attribute array and displayin' the each string in the array.....now as far as my knowledge goes(thanks to HFSJ) the first thing in an EL expression has to be an attribute or an EL implicit object...therefore ${array} makes sense....but what about ${item}....its just a variable(neither an attribute in any of the 4 scopes nor an EL implicit object)....The HFSJ book (page 440) says it is bound to tag scope....now is that a new scope altogether? What's the deal here? Could someone please explain.
 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
${item} or ${pageScope.item} is same.
 
Sayak Banerjee
Ranch Hand
Posts: 292
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see....I figured it out now...you can check this too...when you run the loop, for each iteration, "item" is bound to page scope and removed at the end of the iteration....so "item" is basically a temporary page-scoped attribute for each iteration....therefore inside the loop body ${item} and ${pageScope.item} is the same...

Hey...Thanks man...that was a nice bit of information...definitely not on the book
 
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Sayak,

I feel that I have to defend the HFSJ book. On page 440, we say in the Watch It! "That's right, tag scope. No this isn't a full-fledged scoped..."

I guess that we should have not made-up a name, but the concept is useful. Many custom tags (and JSTL tags) will create temporary attributes, usually in the page scope, but could also be in the request scope. These will only exist for the duration of the tag as you have accurately surmised. Think of this in the same way that you would think of the "scope" of a for-loop variable:


Cheers,
Bryan
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!