You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by "Mallinath Suralikal (C)" <Ma...@neoforma.com> on 2004/06/10 21:49:34 UTC

adding Cookie - request object doesn't get updated.

Hi,
 
I am adding the Cookies using WebRequest.addCookie(String, String).  At the
server side, if I do getCookies(), it's returning null. Looks like the
cookies are not updated on the request. 
 
Thanks
Malli

RE: adding Cookie - request object doesn't get updated.

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Mallinath,

You must be doing something wrong... :-)

Try simplifying the problem until it works and then find out the error in
your code.

Have you tried writing and testing the following:

    public void beginCookieEncoding(WebRequest theRequest)
    {
        theRequest.addCookie("testcookie", "whatever");
    }

    public void testCookieEncoding()
    {
        javax.servlet.http.Cookie[] cookies = request.getCookies();

        assertNotNull("No cookies in request", cookies);

        for (int i = 0; i < cookies.length; i++)
        {
            if (cookies[i].getName().equals("testcookie"))
            {
                assertEquals("whatever", cookies[i].getValue());
                return;
            }
        }

        fail("No cookie named 'testcookie' found");
    }

-Vincent

> -----Original Message-----
> From: Mallinath Suralikal (C) [mailto:Mallinath.Suralikal@neoforma.com]
> Sent: jeudi 10 juin 2004 21:50
> To: Cactus Users List
> Subject: adding Cookie - request object doesn't get updated.
> 
> Hi,
> 
> I am adding the Cookies using WebRequest.addCookie(String, String).  At
> the
> server side, if I do getCookies(), it's returning null. Looks like the
> cookies are not updated on the request.
> 
> Thanks
> Malli
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.711 / Virus Database: 467 - Release Date: 25/06/2004
>