Tables are in HTML to be represented by <table>
element. You should be using JSP for HTML code to separate view from the controller (which will greatly increase maintainability). You could use JSTL to control the flow in JSP. You can use JSTL <c:forEach>
tag to iterate over a collection.
In the servlet, put the list in the request scope and forward to a JSP:
request.setAttribute("dataList", dataList);
request.getRequestDispatcher("/WEB-INF/dataList.jsp").forward(request, response);
In the /WEB-INF/dataList.jsp
, you can present it in a HTML <table>
as follows:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
...
<table>
<c:forEach items="${dataList}" var="dataItem">
<tr>
<td>${dataItem.someProperty}</td>
<td>${dataItem.otherProperty}</td>
</tr>
</c:forEach>
</table>
See also: