Populate JSP dropdown with database info
Posted
by Cano63
on Stack Overflow
See other posts from Stack Overflow
or by Cano63
Published on 2010-05-25T00:13:26Z
Indexed on
2010/05/26
13:01 UTC
Read the original article
Hit count: 433
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;
}
© Stack Overflow or respective owner