Reputation: 13
I am kind of new to JSP. I have got some PHP experience.
I am trying to find a way to store the arraylist data retrieved from a java class file to an array in jsp.
JSP code:
<c:forEach items="${mybean.status}" var="element">
<c:out value="${element}" />
</c:forEach>
Can I store the output retrieved from class file to an array in jsp?
I am looking for something like below. Can this be done with jstl?
String []s = new String[count];
for(int i=0;i<=count;i++) {
s[i] = element ;
}
Thanks in advance.
Upvotes: 0
Views: 1016
Reputation: 1102
Sure you can.. even you can store it at once with array.. i did this code using jstl + spring MVC and i got a + button (to add rows) and - button to delete the row (with javascript):
<c:forEach items="${customer.contacts}" varStatus="i">
<tr>
<td><form:hidden path="contacts[${i.index}].id" /> <form:input
path="contacts[${i.index}].desc" type="text" /></td>
<td><form:input path="contacts[${i.index}].number"
type="text" /></td>
<td><button type="button" class="btnbg2" id="del">-</button></td>
</tr>
</c:forEach>
anda when submit it will store all the list in database
Upvotes: 2