----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
2 things:
1) The first time a client hits your servlet, you need to encode the
redirect-URL to include the session ID. Use encodeURL() or
encodeRedirectURL(). A cookie with the session ID is set at the same
time. In subsequent hits, the encoding is not needed, since the browser
will probably be sending back the cookie. But the first time, you can't
know if the client allows cookie or not.
2) Make sure the Host: header value from the client matches your server
name. My recollection is that the session-id cookie has a domain that is
an exact match of the Apache server-name. I was seeing this on NT: I have
a server with NT name 'fafhrd', but Apache server-name
'fafhrd.mycompany.com'. When I would point my browser to
http://fafhrd/servlets/SomeServlet, the sessions would never stick, but
with http://fafhrd.mycompany.com/servlets/SomeServlet, it would all work.
- Fernando
At 11:23 AM 2/22/00 -0500, you wrote:
>Hello,
>I'm trying to session track for password verification. I'm trying to
>save information between servlets with session tracking, but my values
>are not read between the servlets. I'm trying something like what is
>shown below:
>
>+Servlet Data ---------------------------------------------
>//Main file that has the program, we first check to see if the user has
>logged on.
> HttpSession session = req.getSession(true);
> Object done = session.getValue("logon.isDone");
> if (done == null) {
> session.putValue("login.target",
> HttpUtils.getRequestURL(req).toString()) ;
> //login target is saved and we redirect for password verification
> res.sendRedirect(req.getScheme() + "://" + req.getServerName() + ":"
> + req.getServerPort() +
> "/servletLogin.html");
> return;
>}
>//rest of code here
>+----------------------------------------------------
>
>+Servlet Login Handler--------------------------------------
>//login handler
>//code after verifying password is ok
> HttpSession session = req.getSession(true);
> session.putValue("login.isDone", name);
> try {
> String target = (String) session.getValue("login.target");
> if (target != null)
> res.sendRedirect(target);
> return;
> }
> catch (Exception ignored) {}
> res.sendRedirect(req.getScheme() + "://" +
> req.getServerName() + ":" +
> req.getServerPort() +
> "/index.html");
>}
>+----------------------------------------------------
>
>I loose my login.target data and my login.isDone values between
>Redirect()'s. I have made versions that spit out the variables the
>screen, and unless the servlet that sets the variable is running at
>time, the value is null. I have searched on the web a bunch, and I
>can't fiqure out whats wrong. I'm using Red hat 6.0, Jserv1.1, and I'm
>not sure what Apache version (how do I tell). The Apache came with Red
>Hat 6.0. Any help or pointers to help would be
>great.
>
>Thanks,
>Krister
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]