I have an HTML table in my jsp page. This conains text fields and a drop down box.
From my servlet, I want to pass an arraylist of Strings called myData.
Therefore I attempt to use foreach to transfer the data to my html table:
<table border="1" >
<c:forEach items="${myData}" var="result">
<tr>
<td><input name="from0" type="text" value="${result}"/></td>
</tr>
<tr>
<td>
<select name="from8" id="from8" value="${result}">
<option>Yes</option>
<option>No</option>
</select>
</td>
</tr>
</c:forEach>
</table>
The arraylist is a simple arraylist of strings:
ArrayList<String> output = new ArrayList<String>();
//populate arraylist with values here
//forward the arraylist of strings
request.setAttribute("myData ", output);
request.getRequestDispatcher("Home.jsp").forward(request, response);
Unfortunately the output generates multiple tables whose values all correspond to each element in my arraylist.
Based on you given information, I tried to recover your situation. Honestly I couldn’t do that. Here is my try for recovering:
This generates a good looking table. Can you provide an example link with your problem?