Search code examples
javajspeljsp-tags

Can I pass an ArrayList to an EL Expression?


I know that I can pass strings and primitives. But how do I pass an ArrayList?

Snippet:

<form action="select.do" method="POST">
    <p>Select Beer Characteristics: </p>
    Color:
    <my:select optionList="${applicationScope.colorList}" name="color" size="1"/>
    <br><br>
    <input type="submit" value="Submit"/>
</form>

Solution

  • You can pass an ArrayList the same way as you pass any other object and you access individual fields through ${list[i]}. You can find more on el language syntax in this tutorial.