I have problem getting the result of a JSTL variable dynamically. Here is the scenario.
I have defined messages for some status values as follows in the page.
<c:set var=“messagestatus1a” value=“Less than 30 days with ME” /> <c:set var=“messagestatus1b” value=“30 days or more with ME” /> <c:set var=“messagestatus2a” value=“Less than 30 days with JPM”/> <c:set var=“messagestatus2b” value=“30 days or more with JPM” />
I get a status value from the database (such as status1a, status1b, status2a, status2b) and I am concatenating with ‘message’ so that I can frame the appropriate variable name.
<c:forEach var=“suggestionsLoop” items=“${suggestionQuery.rows}”>
<c:set var=“msgDesc” value=“message${suggestionsLoop.status}” />
<!-- Now, ‘msgDesc’ variable has a value like ‘messagestatus1a’ or ‘messagestatus1b’ etc.,
I would like to reprocess the value from msgDesc to diaplay the appropriate message.
If I try ${${msgDesc}} obviously I am getting error. Any ideas how to accomplish this ?
–>
</c:forEach>
at worst, you could just include a JSPF (fragment) that doesnt have XML bounds set on it. Would allow you construct the dynamic variable without a problem then.