Guest User

Untitled

a guest
Jul 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1. <%--
  2.     Document   : index
  3.     Created on : 28/02/2012, 00:00:15
  4.     Author     : Rodrigo Régio de Araujo
  5. --%>
  6. <%@page import="com.JavAgenda.Uteis.TestesUsuario"%>
  7. <%@page import="com.JavAgenda.Beans.Usuario"%>
  8. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  9. <!DOCTYPE html>
  10. <html>
  11.     <head>
  12.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13.         <title>JSP Page</title>
  14.     </head>
  15.     <body>
  16.         <%
  17.             Cookie ck5=null;
  18.             Cookie cookies5[]=request.getCookies();
  19.             int l=0;
  20.             if(cookies5!=null){//Se a lista de cookies for diferente de null
  21.                 for(int i=0;i<cookies5.length;i++){//Procura os cookies um por um
  22.                     if(cookies5[i].getName().equals("ID")){//Se o cookie de indice i tiver um nome igual a id
  23.                         ck5=cookies5[i];//cookie recebe o cookie de indice i
  24.                     }
  25.                    
  26.                 }
  27.             }
  28.             if(ck5!=null){//Se o cookie for diferende de nulo
  29.                 TestesUsuario teste=new TestesUsuario();//Crio uma nova classe que trabalha com banco de dados
  30.                 Usuario u=teste.retornarUsuarioPorID(Integer.parseInt(ck5.getValue()));//Usuario u recebe o usuario retornado pelo banco
  31.             %>Usuario já logado...<br/><br/>Seja bem vindo <%=u.getNome()%><br/><a href='Sistema.jsp'>Voltar</a> para a página do sistema
  32.  
  33.         <!--Esta é a minha duvida, o que devo fazer mais para esse botão funcionar??-->
  34.             <br/><input type="button" value="Sair do sistema" /><%
  35.             } else {//Se o cookie for igual a nulo o sistema pede para ele logar...
  36.         %>
  37.         <form action="validarLogin.jsp" method="POST">
  38.             <table border="1">
  39.                 <thead>
  40.                     <tr>
  41.                         <th colspan="2">Entre no sistema</th>
  42.                     </tr>
  43.                 </thead>
  44.                 <tbody>
  45.                     <tr>
  46.                         <td>Usuario</td>
  47.                         <td><input type="text" name="usu" value="" size="15" /></td>
  48.                     </tr>
  49.                     <tr>
  50.                         <td>Senha</td>
  51.                         <td><input type="password" name="sen" value="" size="15" /></td>
  52.                     </tr>
  53.                     <tr>
  54.                         <td><a href="registrar.jsp">Registrar</a></td>
  55.                         <td><input type="submit" value="Entrar" /></td>
  56.                     </tr>
  57.                 </tbody>
  58.             </table>
  59.         </form><%
  60.             }
  61.         %>
  62.     </body>
  63. </html>
Add Comment
Please, Sign In to add comment