You need to set the Max Age of the cookie.  If you don't it defaults to
going away when the browser is closed.  You should also set the Path to "/"
so that it will be returned on all pages of your site.
    (*Chris*)

----- Original Message -----
From: "Baker, Robert E" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 10, 2002 12:26 PM
Subject: Re: [JSP-INTEREST] Checking prior registration with initial JSP
page (cookies?)


> Yes, the request does exist (that's why it's in quotes), but it's not
> picking up the cookies for some reason.
>
> I know the cookies are there, because I display them for debugging
purposes
> after successful registration.  Plus I verified the cookie file is in the
> "Cookies" directory.  :-)
>
> Here's the code I'm using to try and display them:
>
> <%
>    Cookie[] cookies = request.getCookies();
>    if (cookies != null) {
>       for (int i=0; i < cookies.length; i++) {
>          String name = cookies[i].getName();
>          String value = cookies[i].getValue();
>          out.println("Cookie : Name [" + name + "], Value [" + value +
> "]<BR>");
>       }
>    } else
>       out.println("There are no cookies.<P>");
> %>
>
> Pretty basic code, but I always get the "There are no cookies" message
when
> I first visit this initial page.
>
> Bob
>
> -----Original Message-----
> From: Chen, Gin [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 10, 2002 3:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Checking prior registration with initial JSP page
> (cookies?)
>
>
> There's an error in your thinking. The response doesnt exist without the
> request. So the request does already exist. Just call getCookies on it and
> you should be fine.
> -Tim
>
> -----Original Message-----
> From: Baker, Robert E [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 10, 2002 2:49 PM
> To: [EMAIL PROTECTED]
> Subject: Checking prior registration with initial JSP page (cookies?)
>
>
> I am working on logins/registrations using just JSP, Servlets and JDBC.
By
> default, when a user gets to the home page (JSP), they can (currently)
> either Log In or Register.
>
> Everything with registering and logging in is working perfectly fine, but
> what I would like to do is have the browser automatically forwarded to the
> login page if they are already registered.  For example, if they are
already
> registered, when they browse to http://www.mysite.com/index.jsp, I want
the
> browser to automatically go to http://www.mysite.com/login.jsp instead.
>
> I can do the forwarding part of this solution with no problem, but I'm not
> sure of the best way to handle the check to see if they are already
> registered.  When they create a new account, I create a cookie with the
> appropriate information in it (which also works), but the JSP can't get
> cookies from the implicit response object (I'm assuming) because the
request
> doesn't "exist" yet.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to