
Problema con variables de session
Publicado por Adrian (11 intervenciones) el 22/08/2007 19:00:28
Hola
tengo un problema algo raro, tengo un simple jsp que setea atributos de session(session key) y este tiene un form con algunos campos de tipo input y un boton de submit. cuando hago submit llama a otra jsp por medio del metodo post esta jsp lee los valores de session. El problema es que si lo ejecuto desde mi browser local anda bien pero si lo ejecuto desde otra computadora la segunda jsp me retorna valores nulos para mis variables de sesiion, pareceria como que se pierden dichos valores alguien tiene alguna idea de lo que puede estar pasando. tendre que setear algo en el tompcat??? les paso el codigo de las dos jsp
gracias
Adrian
test1.jsp
code:
--------------------------------------------------------------------------------
<html>
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<% session.setAttribute("session_key", "ABDCEF0123456789");%><html>
<head>
<title>Set session attribute</title>
</head>
<form action="./test2.jsp" method="post">
<body>
<a href="./test2.jsp">Click here</a>>
Enter your personal information<br>
First Name <input name="fname" type="text" size="20"><br>
Last Name <input name="lname" type="text" size="20"><br>
<input type="submit" value="Go!"> <
</body>
/form>
</html>
--------------------------------------------------------------------------------
test2.jsp
code:
--------------------------------------------------------------------------------
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Get
<html>
<head>
<title>session attribute</title>
</head>
<body>
Your name is <%= request.getParameter("fname") %> <%= request.getParameter("lname") %>.<br>
The session key is <%= (String) session.getAttribute("session_key") %>
</body>
</html>
--------------------------------------------------------------------------------
tengo un problema algo raro, tengo un simple jsp que setea atributos de session(session key) y este tiene un form con algunos campos de tipo input y un boton de submit. cuando hago submit llama a otra jsp por medio del metodo post esta jsp lee los valores de session. El problema es que si lo ejecuto desde mi browser local anda bien pero si lo ejecuto desde otra computadora la segunda jsp me retorna valores nulos para mis variables de sesiion, pareceria como que se pierden dichos valores alguien tiene alguna idea de lo que puede estar pasando. tendre que setear algo en el tompcat??? les paso el codigo de las dos jsp
gracias
Adrian
test1.jsp
code:
--------------------------------------------------------------------------------
<html>
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<% session.setAttribute("session_key", "ABDCEF0123456789");%><html>
<head>
<title>Set session attribute</title>
</head>
<form action="./test2.jsp" method="post">
<body>
<a href="./test2.jsp">Click here</a>>
Enter your personal information<br>
First Name <input name="fname" type="text" size="20"><br>
Last Name <input name="lname" type="text" size="20"><br>
<input type="submit" value="Go!"> <
</body>
/form>
</html>
--------------------------------------------------------------------------------
test2.jsp
code:
--------------------------------------------------------------------------------
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Get
<html>
<head>
<title>session attribute</title>
</head>
<body>
Your name is <%= request.getParameter("fname") %> <%= request.getParameter("lname") %>.<br>
The session key is <%= (String) session.getAttribute("session_key") %>
</body>
</html>
--------------------------------------------------------------------------------
Valora esta pregunta


0