----- Original Message -----
From: "Paromita Choudhury" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 11, 2001 9:57 PM
Subject: Verify request params after redirect
> Hi,
>
> What's the correct way to test that the request
> parameters are cleared after a sendRedirect() is
> executed by the servlet. Should this be tested in
> the testXXX() method?
>
> I have the following code:
>
> public void beginRedirect(ServletTestRequest
> theRequest)
> {
> System.out.println("in beginRedirect");
> theRequest.addParameter("name2", "xyz");
>
> }
>
>
> public void testRedirect() throws Exception
> {
> System.out.println("in testRedirect");
> SampleServlet servlet = new SampleServlet();
> System.out.println("name2= "+
> request.getParameter("name2"));
> servlet.doRedirect(request, response, config);
> System.out.println("name22= "+
> request.getParameter("name2"));
> }
>
> The request parameters are present even after the call
> to doRedirect().
That's normal as you are doing the call to getParameter() on the first HTTP
request object, which has not been modified. What the sendRedirect() does is
return a special HTTP response to the client side (I can't remember the
exact HTTP code returned but probably something in the range 3xx), telling
it to make a new HTTP call to another URL ... The client side part of Cactus
does not handle returned HTTP codes at all (you can consider it a limitation
or a by design feature as the goal is to unit test the _server side_ code).
If you wish you can verify that the response returned to the client side is
the one you would expect by checking the returned code and HTTP headers and
cookies in the endXXX() method.
>
> Thanks for any ideas.
You're welcome.
-Vincent