Possible Duplicate:
Java add all table data into list
+--------+-------+-----+
| Name |number |qty |
+--------+-------+-----+
| ab | 5 | 7 |
+--------+-------+-----+
| cd | 1 | 6 |
+--------+-------+-----+
| ef | 0 | 9 |
+--------+-------+-----+
| gh | 8 | 2 |
+--------+-------+-----+
I add all data in Product to Array List as shown below
public List<Product> search(){
List<Product> products = new ArrayList<Product>();
ResultSet rs = DAO.fetch("SELECT * FROM Products");
while (rs.next()) {
product = new Product();
product.setNumber(rs.getString("ProductNumber"));
product.setName(rs.getString("ProductName"));
product.setQty(rs.getString("ProductQty"));
products.add(product);
}
return products;
}
How do i print all names in my jsp by using this?
You can pass the list by saying the below statement in the controller
And, in your JSP you can use the following code (I am considering you know how to use include JSTL Libraries on your JSP Page).
For using the JSTL Core library, you will need to add the below line in your JSP
And then you can display the traverse the passed list to display all the products.
Hope it helps.