Java Reference
In-Depth Information
After deploying our application we can see the resulting page.
The technique illustrated in this example is very common. Very frequently an
<sql:query>
tag is used, followed by a
<c:forEach>
tag used to generate a database
table from the result set. Since the technique is so common, NetBeans provides an
item in its palette to generate both the
<sql:query>
tag and the
<c:forEach>
tag,
including the static markup for the table just before and after the
<c:forEach>
tag.
To take advantage of this functionality, we simply drag the
DB Report
item from the
NetBeans palette into our page.
After dropping the
DB Report
item into our page, we get a window that is very
similar to the one we get when dropping the
DB Query
item. After entering values for
the
Variable Name
,
Scope
,
Data Source
, and
Query Statement
fields, the following
markup is generated in the location where we dropped the
DB Report
item.
<sql:query var="result" dataSource="jdbc/sample">
SELECT name, city, state FROM customer
</sql:query>
<table border="1">
<!-- column headers -->