Hi,

In article <[EMAIL PROTECTED]>,
Wed, 29 Sep 2004 15:54:43 +0100,
Mamadou Cisse <[EMAIL PROTECTED]> wrote: 
mamadou> In doPost a command object is created from the parameter request. This 
mamadou> command object does some processing and then returns a String as URL to 
mamadou> the doPost method which in turn tries to forward the call. The 
mamadou> pseudocode looks like:
mamadou> {pseudocode ---
mamadou> Command command = CommandFactory.getCommand(request), //1
mamadou> String urlStr = command.execute(); //2
mamadou> RequestDispatcher disp = request.getRequestDispatcher(urlStr); //3
mamadou> disp.forward(request, response); //4
mamadou> --- pseudocode}
mamadou> On the line //4 there is a NullPointerException. The reason is that the 
mamadou> originalDispatcher in the RequestDispatcher instance is null.

ServletRequest#getRequestDispatcher(String) returns null
if the servlet container cannot return a RequestDispatcher.
So, I think, the point is that the urlStr value returned from command.execute()
is valid or not.

You might separate the test into some parts like:
    public void testCommand {
        Command command = CommandFactory.getCommand(request);
        assertEquals("expectedUrl", command.execute());
    }
    public void testDispatch {
        assertNotNull(request.getRequestDispatcher("expectedUrl"));
    }

I guess testCommand() fails and/or your expectedUrl is not valid
for your container.

Hope this helps,
----
Kazuhito SUGURI
mailto:[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to