Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL Question  RSS feed

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
Currently I am using JSTL forEach, as below



Can anyone please help me on this?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, you should use 'c' for the prefix, not core. Following conventions makes code earlier to read and understand.

Secondly, you cannot nest the ${} delimiters inside another set. It's not a fetch operator, but a set of delimiters that go around the entire EL expression. To reference a scoped variable within the expression, just name the variable. Do not try to surround it with another set of delimiters.

And, be sure to use code tags when posting code or code fragments.
 
olivier dutranoit
Ranch Hand
Posts: 81
IBM DB2 Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi,

whay don't you use the following?



with elements is your list of "element",
witch is your element-bean
with a method called getFirstName()...

 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear for the suggestion, i edited my post to include code tags. Can you please explain in detail on how to name a variable, so that i get hold to it. A code snippet, would make it much better.

@oliver, here my elements itself is an array, i don't know how many elements can come.so iterating over just elements will not get me the results.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To reference variable i within an EL expression, you use i, not ${i}
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.. I got it now..
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!