Almost all applications deal with tabular data of some kind. An application management tool typically shows a list with statistics for installed applications and allows an operator to start and stop applications from the list, and a human resource application may display a list of employees and let an administrator select and edit the profile for any one of them. The sample application we develop in this book works with two sets of tabular data: the list of all expense reports and the list of entries for an individual report.
In this chapter, we look at different ways to display and manipulate tabular data, ranging from displaying a simple read-only listing to developing an editable table.
With Java, you can represent tabular
many different ways. Commonly, it's represented as a
java.util.List or array with beans or
java.util.Map instances representing the columns
for each row. If the data is stored in a database, a
java.sql.ResultSet or a
javax.servlet.jsp.jstl.sql.Result object typically
<c:forEach> action supports
looping over all these data types, with
the exception of
java.sql.ResultSet, so if all you
need is rendering a read-only list or table, you can use JSTL just as
you would in a regular JSP page. I actually used this approach in
Chapter 8, to verify that the entries added by the action method for the Add button in the report entry form actually were added to the list: ...