I have to display data fetched from DB to JSP. I am using spring MVC. I have stored data in List in java. Now i need to access this list in JSP and display it in tabular form.
You can add your data in session and access it in table.jsp.
Once you get data on JSP you can easily render as you want using html + jsp combination.
Hope this helps.
List<List<?>> data = new ArrayList<List<?>>();
int col = -1;
List<?> row;
while(rs.next())
{
if (col != rs.getInt(1))
{
col = rs.getInt(1);
row = new ArrayList<?>();
data.add(row);
}
row.add(rs.getObject(3));
}
getRequest().setAttribute(data);
Process it on servlet and store it in 2D array of String or List<List<String>>
Set it as attribute to request, forward request to jsp.
on jsp use JSTL to represent data. using <c:forEach>