|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Junior Member
Iscritto dal: Aug 2008
Messaggi: 2
|
[Jsp] salvare nella request
Salve a tutti!! Premetto chesono alle prime armi con jsp ,vorrei sapere come faccio a salvare la scelta di una select option nella request e a stamparla nella pagina successiva??? Ho provato così ma..... non mi funziona
<form method="post" action="estrai.jsp"> <fieldset> <legend>Scelta Prodotti</legend> <label for="prodotto"> </label> <table> <tr> <td>Prodotto </td> <select name="prodotto" id="prodotto"> <option>Seleziona un prodotto</option> <% Connection conn = null; PreparedStatement st = null; ResultSet rs = null; String driver = "org.gjt.mm.mysql.Driver"; Class.forName(driver); try { conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/basedati","root","password"); st = conn.prepareStatement("SELECT codice,tipo,descrizione FROM prodotti order by tipo "); rs = st.executeQuery(); while(rs.next()){ Prodotto p= new Prodotto(); p.setCodice(rs.getString("codice")); p.setTipo(rs.getString("tipo")); p.setDescrzione(rs.getString("descrizione")); %> <option value="a1"> <%=p.tipo%> - <%=p.descrizione%> </option> <% } }catch (SQLException sqle) { throw new SQLException("Errore persistenza" +sqle); }finally { if(conn != null) rs.close(); st.close(); conn.close(); } %> </td> </tr> </select> </table> <input type="submit" value="view"/> </fieldset> </form> <% String prodotto = request.getParameter( "prodotto" ); %> nella pagina successiva ho provato a scrivere così.. <% String prodotto =(String)request.getAttribute( "prodotto"); // String prodotto = (String)request.getAttribute("prodotto"); out.println("<p>"+prodotto+"</p>"); %> mi stampa null Dove sbaglio?????? Grazie in anticipo!!! |
![]() |
![]() |
![]() |
#2 |
Junior Member
Iscritto dal: Mar 2008
Città: Bolgare(BG)
Messaggi: 23
|
hai provato il request.getParameter(<nome parametro>); ?
__________________
---Ci sono 10 categorie di persone... chi conosce il binario e chi no--- |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 12:57.