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

accessing n value of a list  RSS feed

 
wbrian radley
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there,

given a bean - called abean- stored in the session which has as a field an ArrayList<String> - called labels;
at different points in the jsp file I need at access a particular element in the list;
for example: labels.get(3) in one place and at another labels.get(4);
in my situation a forEach loop would not be appropriate.



I tried but the output was blank
generated an error.

I looked for an answer but found none; is it possible?

any assistance would be greatly appreciated.

B
 
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
${abean.labels[3]} is the correct syntax.

If it's blank, either it's beyond the end of the List, or the construct is simply not what you think it is.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!