voilà j'ai une jsp qui contient une liste SELECT que je veux remplir à partir d'une table de ma bdd, que voici le code:
et voici le code de ma jsp:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 public String[] arrayFil = new String[]{}; public String[] fillList(String table, String champs) { List rowValues = new ArrayList(); String query = "SELECT " + champs + " FROM " + table; try { stat = cnx.prepareStatement(query); rslt = stat.executeQuery(); while (rslt.next()) { //int i = 1; rowValues.add(rslt.getString(1)); //array.add(rslt.getString(i++)); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (rslt != null) { rslt.close(); } } catch (Exception e) { }; try { if (stat != null) { stat.close(); } } catch (Exception e) { }; } arrayFil = (String[]) rowValues.toArray(new String[rowValues.size()]); return arrayFil; }
quand je déroule ça me donne des emplacements vides
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <select> <option name="filiere" value="0"></option> <% DBinstructions obj = new DBinstructions(); String[] Fil = new String[]{}; Fil = obj.fillList("filiere", "filiere"); for (int i = 0; i < Fil.length ; i++) { %> <option name="filiere" value="1" > <% Fil[i].toString();%> </option> <% } %> </select>
je n'arrive pas à trouver l'erreur
Partager