PDA

View Full Version : JSP ${param. } concatenation help


HeavensCloud
06-03-2009, 09:29 AM
Hello all, I'm currently enrolled in a Web Architecture course and in ten weeks we have briefly covered 7 different languages. I need some help with JSP issue. i'm pretty sure the solution is simple but all this code in a short time is making my brain turn to mush. Any help would be greatly appreciated.

I have a JSP page that has several sets of radio buttons. Each set holds the answer to a question and each set is labeled "q1" "q2" ect. I need to be able to retrieve the value of each set of buttons dynamically. What is the syntax to add a dynamic variable to the ${param.}


<c:forEach var="row" items="${emp.rowsByIndex}" varStatus='rnum'>
<c:out value='${param.q"rnum.index"}' />
</c:forEach>


where q"rnum.index" is the current position in the loop with a 'q' in front of it. Over the past two hours i have tried every configuration i can think of. I also tried using <c:set> to save string variables in stages but couldn't get that to work either. please help

HeavensCloud
06-03-2009, 07:32 PM
i was able to work out an answer to my own question. i wasn't able to figure out how to concatenate multiple strings to a param so i concatenated one string at a time and stored it to a var.


<c:forEach var="row" items="${emp.rowsByIndex}" varStatus='rnum'>
<c:set var='hold' value='q${rnum.index}' />
<c:set var='holder' value="${param[hold]}" />
</c:forEach>


now if you reference ${holder} you get the value of the question radio button that shares its name with the position currently in the loop. Hopefully this helps someone else.