Hello,
I'm now encounting a problem on session when
redirecting to a .html file using a servlet.
There involve three servlets. In the first one, I create a
session using the following codes:
HttpSession session = req.getSession(true);
Integer logined = (Integer)session.getValue("login.flag");
if (logined == null)
{
Integer tmpint=new Integer(0);
session.putValue("login.flag", tmpint);
Integer logined = (Integer)session.getValue("login.flag");
if (logined == null)
{
Integer tmpint=new Integer(0);
session.putValue("login.flag", tmpint);
session.putValue("register.flag","0");
}
Then, in the second one, I get the "register.flag"
from the session and if its value is "0", I set the URL to redirect to
a register.html. The code is: res.sendRedirect(".../register.html").
The URL string is the absolute URL.
Well, the second servlet is running well. I get the
register.html through redirecting. In the register.html, I have a form, which
action is the third servlet. In the third servlet, I try to get the
"login.flag" and "register.flag" from the session, but the
result is "null". The testing showed that the session created in the
third servlet is new.
I wonder whether the redirect action cause the session to
disappear. How to solve the problem?
Could anyone give me a help?
Great thanks.
Qian Jianhua
1999.5.20
