Using this Java
snippet the users can Populate Dropdown from a DB
//Code to Populate Dropdown from a DB// //In JSP// <div id="bodydiv" align="center" > <select name=" Name" onchange="this.form.submit();"> <option name="Router Name" value="0">--------select--------</option> <% GetXRouter dao = new GetXRouter(); ArrayList ReList = dao.retreiveRname(); for (int i = 0; i < ReList.size(); i++) { %> <option name="RName" value="<%=ReList.get(i)%>"><%=ReList.get(i)%></option> <% } %> </select> //IN Java Class File// public class GetList { static Connection conn = null; static Statement st = null; static ResultSet rs = null; static DBConnection db; @SuppressWarnings({ "rawtypes", "unchecked" }) public ArrayList retreiveIname(String Rname) throws SQLException { Connection conn; DBConnection db = new DBConnection(); conn = db.getConnection(); Statement st; st = conn.createStatement(); ResultSet rs = st.executeQuery("select tt.Y_nm from Z.Z_X_Y_cfg tt where tt.active = 'A' and tt.X_nm = '"+Rname+"' "); ArrayList IList = new ArrayList(); while (rs.next()) { IList.add(rs.getString(1)); } for (int i = 0; i < IList.size(); i++) { System.out.println(IList.get(i)); } return IList; } }