Advertisement
wanny

ALEèGAY

Jul 25th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. Pagina JSP
  2. ###########
  3.  
  4. <jsp:useBean id="utente" class="utente.datiUtente" scope="session"/>
  5. <jsp:setProperty name="utente" property="*" />
  6. <jsp:useBean id="sessione" class="utente.sessione" scope="session"/>
  7.  
  8. <%@ page import="java.util.ArrayList" %>
  9. <%@ page import="java.util.List" %>
  10.  
  11. <%
  12. List<String> utentiRegistrati = new ArrayList<String>();
  13. utentiRegistrati.add("wanny");
  14. utentiRegistrati.add("mario");
  15.  
  16. if(utentiRegistrati.contains(utente.getUsername())){ %>
  17. <strong> UTENTE REGISTRATO</strong>
  18. <% sessione.incrementaContatore(); %>
  19.  
  20. <% }else{ %>
  21. <strong> UTENTE NON REGISTRATO</strong>
  22.  
  23. <% } %>
  24.  
  25. Numero Sessione : <%= sessione.getCount() %>
  26.  
  27. <Form method="POST" ACTION="">
  28. username: <input type="text" name="username"><br/>
  29. password: <input type="password" name="password"><br/>
  30. <input type="submit" value="Invia">
  31. </Form>
  32.  
  33. ###########
  34. Classe Utente
  35. ###########
  36.  
  37. package utente;
  38.  
  39. public class datiUtente {
  40.  
  41. String username;
  42. String password;
  43.  
  44. public void setUsername(String value)
  45. {
  46. this.username= value;
  47. }
  48.  
  49. public void setPassword(String value)
  50. {
  51. this.password= value;
  52. }
  53.  
  54. public String getUsername() { return this.username; }
  55. public String getPassword() { return this.password; }
  56.  
  57. }
  58.  
  59. #############
  60. Classe JAVA contatore sessione
  61. #############
  62.  
  63. package utente;
  64.  
  65. public class sessione {
  66.  
  67. int countSession;
  68.  
  69. public void setCountSession(int value)
  70. {
  71. this.countSession = value;
  72. }
  73.  
  74. public int getCount()
  75. {
  76. return this.countSession;
  77. }
  78.  
  79. public void incrementaContatore()
  80. {
  81. this.countSession += 1;
  82. }
  83.  
  84. }
  85.  
  86. ##############
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement