I don't do Jena, but basically you would like to iterate over the com.hp.hpl.jena.query.ResultSet
and map the information into a List<RowObject>
where RowObject
is your own model class which represents a single row you'd like to display in a HTML table. After mapping, put the List<RowObject>
in the request scope and forward the request to a JSP.
List<RowObject> results = getItSomeHow();
request.setAttribute("results", results); // Will be available as ${results} in JSP
request.getRequestDispatcher("page.jsp").forward(request, response);
Then in JSP, use JSTL c:forEach
to iterate over the List<RowObject>
, printing a HTML table.
<table>
<c:forEach items="${results}" var="rowObject">
<tr>
<td>${rowObject.someProperty}</td>
<td>${rowObject.anotherProperty}</td>
...
</tr>
</c:forEach>
</table>
Update based on your other answer, here's how you could create a List<RowObject>
based on the Jena's ResultSet
:
List<RowObject> results = new ArrayList<RowObject>();
while (rs.hasNext()) {
RowObject result = new RowObject();
QuerySolution binding = result.nextSolution();
result.setInd(binding.get("ind"));
result.setSomethingElse(binding.get("something_else"));
// ...
results.add(result);
}
And display it as follows:
...
<td>${rowObject.ind}</td>
<td>${rowObject.somethingElse}</td>
...