<form> <select name="source" style="width:180 px"></select> <c:forEach items="${slist}" var="ls"> <option> <c:out value="${ls}"/></option> </c:forEach> </form>
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try{ Class.forName("com.mysql.cj.jdbc.Driver"); Connection con=DriverManager.getConnection( "jdbc:mysql://localhost:3306/dbname","root","password"); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from City"); while(rs.next()) { i=rs.getInt(1); val=rs.getString(2); ar.add(val); } request.setAttribute("slist",ar); request.getRequestDispatcher("/WebContent/Home.jsp").forward(request, response); //rd.forward(req,res); //System.out.println(rs.getInt(1)+" "+rs.getString(2)+" "); con.close(); }catch(Exception e){ System.out.println(e);} finally { } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)