The easiest way to add an <sql:query> tag to one of our JSPs is to simply drag the
DB Query item from the NetBeans palette into our page.
After dropping this item into our page, we are prompted for additional information.
The Variable Name field is the name that will be given to the variable that will hold
the result set generated by our query. The Scope field is the scope where this variable
will be stored; the variable can be stored on any valid scope ( page , request , session ,
or application ). The Data Source field is for the JNDI name of the data source we
will be using to obtain a connection to the database, this data source must be added
as a resource reference to our web application's web.xml deployment descriptor, as
explained in the previous section.
After entering appropriate values for all fields and clicking OK , the following
markup is generated in our page:
<sql:query var="allRows" dataSource="jdbc/sample">
SELECT name, city, state FROM customer