Alex Rivera | Logout

How do I dynamically access request parameters with JSP EL?

Asked 2009-01-19T18:52:53.780
15

I'm looping through a list of items, and I'd like to get a request parameter based on the item's index. I could easily do it with a scriptlet as done below, but I'd like to use expression language.

<c:forEach var="item" items="${list}" varStatus="count">

   <!-- This would work -->
   <%=request.getParameter("item_" + count.index)%>

   <!-- I'd like to make this work -->
   ${param.?????}

</c:forEach>
Edit
Report

2 Answers

17
<c:set var="index" value="item_${count.index}" />
${param[index]}

Unfortunately, + doesn't work for strings like in plain Java, so

${param["index_" + count.index]}

doesn't work ;-(

answered 2009-01-19T18:54:55.880
-1

Short answer:

${param.item_[count.index]}
answered 2011-03-23T09:31:21.287

Your Answer