I have an Arraylist of Arraylist< String>’s and I am trying to access a string value. Say I wanted to access the third String in the second ArrayList in my jsp file, but I wanted to do it without scripting, using EL. would this be correct? ${anArrayList[2][3]}
Share
Almost correct. Array indexes start with
0, not1as you seem to think. This has always been the case in normal Java code and this is not different in EL. So, to get the second list and then the third string, you need respectively the indexes1and2. So, this should do…assuming that you’ve already placed
${anArrayList}in the desired scope. For example, in the request scope with help of a preprocessing servlet:By the way, are you familiar with Javabeans? This smells much that you rather need a
List<Entity>.