"Vaishnav, Kunal" wrote:
> 
> Hello All,
>  Sorry for botheration again. I had a query regarding, if I am sending
> cookies in the request object, by doing theRequest.addCookies(...)..how do I
> check in my method which I am calling like servlet.getloginc(..)...that
> cookies are being passed?. In the Simple Servlet example, cookies are
> verified on the client side, but how can I do so on the server side before
> actually using them, so that I know they are being passed correctly.

no, see below, in the sample they are tested server side.


Ok, I'll reply twice, once to you and once to the list.

The following is the code from TestSampleServlet.java:

   /**
     * Verify that we can simulate a single cookie sent in the HTTP
request.
     *
     * @param theRequest the request object that serves to initialize
the
     *                   HTTP connection to the server redirector.
     */
    public void beginSendCookie(ServletTestRequest theRequest)
    {
        theRequest.addCookie("testcookie", "thisisacookie");
    }

>>>>>> beginSendCookie happens on the client side.

    /**
     * Verify that we can simulate a single cookie sent in the HTTP
request.
     */
    public void testSendCookie()
    {
        SampleServlet servlet = new SampleServlet();
        Hashtable cookies = servlet.getRequestCookies(request);

        assert(cookies.get("testcookie") != null);
        assertEquals("thisisacookie", cookies.get("testcookie"));
    }


>>>>>>>>>>>>>>>>>>>>> testSendCookie gets executed on the SERVER side.

You don't seem to have a clear distinction between what happens client
and what happens server side, either that or i misunderstand what you're
trying to do.

The sample is as simple as it can be made -
begin and end - executed on the junit client
setup, test and teardown - executed in the servlet container.

Perhaps a code snippet of what you're trying might help.

Jari

--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to