I want to dynamically create variable names in java el. The problem is that the second line returns sessionScope.saved_activity as a string instead of data.
<c:set var="savedKey" value="sessionScope.saved_${entry.key}" />
<td> <input type="text" name="${entry.key}" value="${savedKey}"> </td>
How can I retrieve the data from 开发者_开发问答a string in el ?
You need to create the sole key name and then use that as a dynamic key of the ${sessionScope}
with the brace notation.
<c:set var="savedKeyName" value="saved_${entry.key}" />
<input type="text" name="${entry.key}" value="${sessionScope[savedKeyName]}">
精彩评论