How to concatenate a string and variable to create a new variable
826051May 23 2011 — edited May 25 2011Hi all,
I am writing a script that goes through a for loop on the java side as well as the jstl side for error checking. I may end up just writing another class to contain the variables I want to use, however I want to know if this is possible.
I have a for loop in the java code which sets the variable to a value to display on the jsp page:
for (ct = 0; ct < count; ct++) {
setValue("check_id_"+ct, "1");
}
I want to be able to evaluate this value from the jsp page, but am having some trouble applying the variable name to contain a number from the for loop. I've tried using embedded variables and concatenating the string and variable with no luck.
${check_id_${row}}
or
<c:set var="id" value="check_id_${row}"/>
${<c:out value="${id}" />}
or easier said, I want to use the value of ${id} as a variable, so the value of the variable ${check_id_${row}} would be displayed.
Any ideas?
Drew
Edited by: user8789152 on May 23, 2011 8:52 AM