Hi,
Looks like Phillip is looking for a way to send cookies from an
HTTP client to a server. It has nothing to do with servlets. The
solution suggested by Jan might be relevant if the client had the
servlet API's with him for his client, but I'm not sure this is
recommanded (the Cookie class is part of the Servlet 2.x spec,
not a standard Java class).
I suspect that just MAYBE, the ":" (colon) in the cookie's value might be
confusing the cookie reader in the server side. Try:
1. Sniffing the net to see that the cookie indeed gets sent.
2. Encode the cookie's value using base64.
3. Send the cookie with nothing appended to it (as in example 2), this
should be the right way.
4. Look in RFC 2109 (on www.ietf.org) and maybe other docs through
www.w3c.org
Hope this helps,
--Amos Shapira
WebCollage
> -----Original Message-----
> From: Jan Andresen [elkware] [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, August 27, 2000 12:10 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Cookie frustration.
>
>
> Hi Phillip!
>
> What are you acutally trying to do ?
> Read the value of a cookie or set a cookie ?
>
> Get the value of a cookie with:
> Cookie cookies[] = request.getCookies();
> String cookieValue=null;
> if (cookies!=null){
> for (int i=0; i< cookies.length; i++)
> if (cookies[i].getName().equals("CookieName"))
> cookieKey=cookies[i].getValue();
> }
> }
>
> set the cookie with:
> Cookie tc = new Cookie("CookieName",cookieValue);
> tc.setMaxAge(maxCookieAge); // int how long the cookie should be valid
> response.addCookie(tc);
>
> remeber, you can only read a cookie from the browser if you
> wrote it there
> first, if a different domain/server wrote a cookie, you can
> not read it!
>
> hope this helps..
>
> c.ya Jan
>
> Phillip Rhodes wrote:
>
> > I am writing a java app that accesses a cookie-using
> > servlet (the servlet I am communicate with is a closed
> > commercial product)
> >
> > I get the cookie via
> > String cookieInfo =
> > connection1.getHeaderField("Set-Cookie");
> >
> > This is what cookieInfo var is...
> > GatewayID=4:967354909482; path=; expires=Fri,
> > 26-Aug-2005 05:41:49 GMT
> >
> > I then create another connection and use the above to
> > set the cookie.
> > connection.setRequestProperty("Cookie",temp);
> >
> > I have tried setting temp to
> > 1) the whole string above
> > 2) GatewayID=4:967354909482
> > 3) GatewayID=4:967354909482;
> >
> > Nothing works. I keep getting an error that means
> > that I don't have a session. Any ideas?
> >
> > Thanks,
> > Phillip
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Mail - Free email you can access from anywhere!
> > http://mail.yahoo.com/
> >
> >
> ______________________________________________________________
> _____________
> > To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
> http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
> http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> --
> Jan Andresen :: New Media Engineer :: http://www.elkware.com
> Phone: ++49 (0) 4103 - 12 45 40
>
> ______________________________________________________________
> _____________
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
> http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html