Populate JSP dropdown with database info
- by Cano63
I'm looking for the way to populate a JSP dropdown. I want that when the JSP loads it fills the dropdown with the info that I have in a database table.
I'm including the code of my class that will create the array and fill it with the database info. What I don't know is how to call that class from my JSP and fill the dropdown.
// this will create my array
public static ArrayList<DropDownBrands> getBrandsMakes() {
ArrayList<DropDownBrands> arrayBrandsMake = new ArrayList<DropDownBrands>();
while (rs.next()) {
arrayBrandsMake.add(loadOB(rs)); // CARGO MI ARREGLO CON UN OBJETO
}
return arrayBrandsMake;
}
// this will load my array object
private static DropDownBrands loadOB(ResultSet rs) throws SQLException {
DropDownBrands OB = new DropDownBrands();
OB.setBrands("BRAN");
return OB;
}