--

Frank Morton wrote:

> --
>
> I have referred to the usual places for help (like the FAQ)
> and still have not had luck setting cookies directly with
> apache-jserv 1.0.
>
> To set the cookie, I am doing:
>
> Cookie cookie = new Cookie("sessionid","1234567890");
> response.addCookie(cookie);
>

One thing to watch out for ... you must do this before sending any
output to the output stream (or writer).  Otherwise, it is likely that
the HTTP headers have already been created (which is how the cookie gets
communicated to the browser), and calling this will have no effect.

>
> I have not seen any way to verify if the cookie was really set.
> Is there a way to do so? I have also tried messing with many
> of the other settings (like setMaxAge) and none seem to
> make any difference.
>

What I do to verify cookies with Netscape (I think there's a similar
gadget in IE) is set the option that says "warn me before accepting a
cookie".  This gives you a pop-up dialog that shows the cookie name and
value, the age (if you set it), and what domains it will get sent back
to.  And, you can choose to accept or not accept the cookie if you want
to test how your app behaves if cookies are turned off.

Edit -> Preferences -> Advanced


>
> Then, to retrieve the cookie I am doing:
>
> Cookie[] cookies = request.getCookies();
>
> No matter what I do, cookies always come back as an
> empty array (using cookies.length). I have done this
> from multiple browsers, so I do think it is on the
> server-side.
>
> This seems so basic, I must be missing something basic.
>
> Help! Thanks.
>

As mentioned above, it's probably the placement of where you try to set
the cookie.

Craig McClanahan




--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to