VARIABLES DE SESION ARCHIVO index.jsp title

Anuncio
VARIABLES DE SESION
ARCHIVO index.jsp
<html>
<head>
<title>Sesiones</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<%
String misesion = "false";
session.setAttribute("misesion", misesion);
%>
<div>POLITECNICO INTERNACIONAL</div>
<FORM METHOD=POST ACTION="sesion2.jsp">
Cual es tu nombre
<INPUT TYPE=TEXT NAME=nombre SIZE=20>
<INPUT TYPE=SUBMIT value="Ingresar">
</FORM>
</body>
</html>
Archivo sesion2.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sesión</title>
</head>
<body>
<h1>pagina 2 - POLITECNICO INTERNACIONAL</h1>
<%
String nombre = request.getParameter("nombre");
if (nombre != null) {
session.setAttribute("elnombre", nombre);
}
String sesion = "true";
session.setAttribute("misesion", sesion);
%>
Hola, <%=session.getAttribute("elnombre")%><br>
<A HREF="sesion3.jsp">Confirmar</A>
</body>
</html>
Archivo sesion3.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sesión</title>
</head>
<body>
<%
if (session.getAttribute("misesion") != "true") {
out.println("acceso no permitido");
} else {
out.println("acceso AUTORIZADO, PUEDE CONTINUAR. <br>");
String nombre = (String) session.getAttribute("elnombre");
%>
Felicidades <%=nombre%>, listo.
<%
}
%>
<h1>POLITECNICO INTERNACIONAL</h1>
<%
String nombre = (String) session.getAttribute("elnombre");
%>
</body>
</html>
Descargar