Ver Mensaje Individual
  #5 (permalink)  
Antiguo 11/05/2011, 03:26
nahasamapetilan35
 
Fecha de Ingreso: marzo-2011
Mensajes: 30
Antigüedad: 13 años, 1 mes
Puntos: 2
Respuesta: Login con JSP

Buenas al final lo he hecho todo con .jsp y pongo el código por si alguien lo necesita algun dia

style.css
Código:

.box-table-encuesta{
font-family: "Calibri", "Lucida Grande", Sans-Serif;
font-size: 11px;
margin: 45px;
width:95%;
text-align: center;
border-collapse: collapse;
border: 1px #F79646;
margin-left:0;
text-align: center;
	
}

.box-table-encuesta th{
font-weight: normal;
background: #F79646;

font-weight: bold;
color: #FFFFFF;
font-size: 14px;
text-align: center;

}

.box-table-encuesta td{

color: #000000;
padding: 3px;
font-align: justify;
font-weight: bold;
}


.box-first-encuesta{
font-weight:bold;
width: 30%;
padding:2px;
text-align: justify;

}

.box-table-encuesta input{
	width: 75%;
	height: 15px;
}

.box-table-encuesta input.enviar{
	width: 20%;
	height: 20px;
	margin-left:45%;
	margin-top:3%;
}



.box-table-encuesta_respuesta{
font-family: "Calibri", "Lucida Grande", Sans-Serif;
font-size: 11px;
margin: 45px;
width:95%;
text-align: center;
margin-left:0;
text-align: center;
border: 1px solid #F79646;
border-collapse: collapse;
	
}

.box-table-encuesta_respuesta th{
font-weight: normal;
background: #F79646;
border: 1px solid #F79646;
font-weight: bold;
color: #FFFFFF;
font-size: 14px;
text-align: center;
border-collapse: collapse;

}

.box-table-encuesta_respuesta td {
border: 1px solid #F79646;
color: #000000;
padding: 3px;
font-align: justify;
font-weight: bold;
border-collapse: collapse;
}


.box-first-encuesta_respuesta{
font-weight:bold;
width: 30%;
padding:2px;
text-align: justify;

}

login.jsp

Código:
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<style type="text/css"></style>
<link rel="stylesheet" href="../css/style.css" type="text/css"/>
<script type="text/javascript" src="../js/script.js"></script>
</head>
<body onload="cambiarTitulo()">
<div class="contenido">



       
        <%
        String myname =  (String)session.getAttribute("username");
       
        if(myname!=null)
            {
             out.println("Welcome  "+myname+"  , <a href=\"logout.jsp\" >Logout</a>");
             
            }
        
              else 
            {
            %>
            <form action="checkLogin.jsp"> 
               <table class="box-table-d" >
               <tr><td colspan="2" ><img alt="Se necesita contraseña" src="../img/locked.gif"/>Login</td></tr> 
                    <tr>
                        <td> Username  : </td><td> <input name="username" size=15 type="text" /> </td> 
                    </tr>
                    <tr>
                        <td> Password  : </td><td> <input name="password" size=15 type="text" /> </td> 
                    </tr>
                    <tr><td colspan="2"><input type="submit" value="login" /></td></tr>
                </table>
                
            </form>
            
            <br/><br/><div class="anuncio_pass"><i> Si no tiene contraseña la puede solicitar, enviando un email a Soporte GSIS usando el botón "Contacta" o enviando un correo a la siguiente dirreción <a href="mailto:[email protected]">[email protected]</a></i></div>
            <% 
            }        
            
            %>     
</div>   
</body>
</html>
checkLogin.jsp

Código:
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<style type="text/css"></style>
<link rel="stylesheet" href="../css/style.css" type="text/css"/>
<script type="text/javascript" src="../js/script.js"></script>
</head>
    
<body>
<div class="contenido">
<%
            String username = request.getParameter("username");
            String password = request.getParameter("password");
            String redirectURLprueba = "http://www.google.es/";
            String redirectURLliveall = "../####/####/pagina.html";
            String redirectURLlogin = "./loginES.jsp";
            
         

            // Here you put the check on the username and password
            if (username.toLowerCase().trim().equals("prueba") && password.toLowerCase().trim().equals("prueba")) {
               // out.println("Welcome " + username + " <a href=\"index.jsp\">Back to main</a>");
               // session.setAttribute("username", username);
            	response.sendRedirect(redirectURLprueba);}
            if (username.toLowerCase().trim().equals("admin1") && password.toLowerCase().trim().equals("admin1")) {
                  response.sendRedirect(redirectURLliveall );                  
            }  
          else 
               {
        	  %>
        	  <table class="box-table-d" >
              <tr><td colspan="2" >Error en la contraseña o usuario, vuelve atras por favor.</td></tr> 
             </table>  
        	 <%
          }

%> 
</div>
    </BODY>
</HTML>

Saludos!