I got the following code:
<c:forEach var="i" begin="1" end="${finalDisccount}">
<p><c:out value="${tracksCD}" /> Tracks für CD${i} hochladen</p>
<p><input id="filename_${i}" type="file" name="filename_${i}" size="50" multiple="multiple" required="required"/></p>
</c:forEach>
The value “tracksCD” has be to concatenated with the variable i, so that something like this is created by the loop:
<p><c:out value="${tracksCD1}" /> Tracks für CD${i} hochladen</p>
<p><c:out value="${tracksCD2}" /> Tracks für CD${i} hochladen</p>
And so on.
Is there a way to combine ${tracksCD} and ${i} to get ${tracksCD1} and so on dynamically?
Thanks in advance.
If you know the scope of the data, then you can just access it in the scope map
${requestScope},${sessionScope}or${applicationScope}. E.g. when it’s in the request scope:However, you’ve there a pretty nasty design mistake. Rather collect them in an array or a list as
${tracksCDs}so that you can do as follows:Or maybe if the
${finalDisccount}happen to have the same size as the array/list: