Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pagina JSP
- ###########
- <jsp:useBean id="utente" class="utente.datiUtente" scope="session"/>
- <jsp:setProperty name="utente" property="*" />
- <jsp:useBean id="sessione" class="utente.sessione" scope="session"/>
- <%@ page import="java.util.ArrayList" %>
- <%@ page import="java.util.List" %>
- <%
- List<String> utentiRegistrati = new ArrayList<String>();
- utentiRegistrati.add("wanny");
- utentiRegistrati.add("mario");
- if(utentiRegistrati.contains(utente.getUsername())){ %>
- <strong> UTENTE REGISTRATO</strong>
- <% sessione.incrementaContatore(); %>
- <% }else{ %>
- <strong> UTENTE NON REGISTRATO</strong>
- <% } %>
- Numero Sessione : <%= sessione.getCount() %>
- <Form method="POST" ACTION="">
- username: <input type="text" name="username"><br/>
- password: <input type="password" name="password"><br/>
- <input type="submit" value="Invia">
- </Form>
- ###########
- Classe Utente
- ###########
- package utente;
- public class datiUtente {
- String username;
- String password;
- public void setUsername(String value)
- {
- this.username= value;
- }
- public void setPassword(String value)
- {
- this.password= value;
- }
- public String getUsername() { return this.username; }
- public String getPassword() { return this.password; }
- }
- #############
- Classe JAVA contatore sessione
- #############
- package utente;
- public class sessione {
- int countSession;
- public void setCountSession(int value)
- {
- this.countSession = value;
- }
- public int getCount()
- {
- return this.countSession;
- }
- public void incrementaContatore()
- {
- this.countSession += 1;
- }
- }
- ##############
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement