+--------+-------+-----+
| Name |number |qty |
+--------+-------+-----+
| ab | 5 | 7 |
+--------+-------+-----+
| cd | 1 | 6 |
+--------+-------+
Make your search()
method return a List
instead of a single Product
.
public List search(){
List products = new ArrayList();
ResultSet rs = DAO.fetch("SELECT * FROM Products");
while (rs.next()) {
Product product = new Product();
product.setNumber(rs.getString("ProductNumber"));
product.setName(rs.getString("ProductName"));
product.setQty(rs.getString("ProductQty"));
products.add(product);
}
return products;
}
Then, in your JSP file, iterate over the returned list: