Search code examples
javajspstrutsstruts-1

Is it possible to access say the 3rd element in a collection with Struts?


Is there a way to do the following thing in Struts / JSP?

<html:checkbox property="list.get(0).checked" />

Thank you in advance.


Solution

  • If you want to access the 3rd element in a list in JSTL, the syntax is just like arrays:

    <html:checkbox property="list[2].checked" />
    

    Note that if you are new to JSTL/EL you'll have to add the appropriate jar to your classpath and reference the tag library.