Advertisement
giorgioancuta

JSP Esercizio

Apr 27th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. * ex.html *
  2.  
  3. <!doctype html>
  4. <html>
  5. <head>
  6. <title>Form</title>
  7. </head>
  8. <body>
  9. <h1>Form di Input</h1>
  10. <form action="ex.jsp" method="get">
  11. Nome <input type="text" name="nome"><br>
  12. Cognome <input type="text" name="cognome"><br>
  13. Automobile <select name="automobile">
  14. <option value="volvo">Volvo</option>
  15. <option value="saab">Saab</option>
  16. <option value="mercedes">Mercedes</option>
  17. <option value="audi">Audi</option>
  18. </select>
  19. <input type="submit">
  20. </form>
  21. </body>
  22. </html>
  23.  
  24. * ex.jsp *
  25.  
  26. <%
  27. String nome = request.getParameter("nome");
  28. String cognome = request.getParameter("cognome");
  29. String automobile = request.getParameter("automobile");
  30.  
  31. session.setAttribute("Automobile", automobile);
  32. session.setAttribute("ilNome", nome);
  33. session.setAttribute("ilCognome", cognome);
  34.  
  35. String a = response.encodeUrl("ex2.jsp");
  36.  
  37. automobile = automobile +" NUOVA";
  38. %>
  39.  
  40. <html>
  41. <body>
  42. <h1> Riepilogo: </h2>
  43. <p> Hai scelto l'automobile <%= automobile %></p>
  44. <a href="<%= a %>">Continua...</a>
  45.  
  46. </body>
  47. </html>
  48.  
  49. * ex2.jsp *
  50.  
  51. <html>
  52. <body>
  53. <h3>
  54. Ciao, <%= session.getAttribute("ilNome") %>! <br>
  55. Il tuo cognome è <%= session.getAttribute("ilCognome") %>!
  56. Hai scelto l'automobile <%= session.getAttribute("Automobile")%>!
  57.  
  58. </h3>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement