jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: Dispatch problem
Date Mon, 11 Feb 2002 22:34:14 GMT


> -----Original Message-----
> From: Vincent Massol [mailto:vmassol@octo.com]
> Sent: 10 February 2002 11:14
> To: 'Cactus Users List'
> Subject: RE: Dispatch problem
> 
> Kim,
> 
> As Nicholas said, these are interesting issues ! ...
> 
> Let me try to answer below.
> 
> > -----Original Message-----
> > From: kim [mailto:kim] On Behalf Of Kim Madsen
> > Sent: 08 February 2002 14:47
> > To: cactus-user@jakarta.apache.org
> > Subject: Dispatch problem
> >
> > I have a few problems with Cactus, which I have been unable to find
> any
> > information about. I got several Cactus test cases which works fine,
> but
> > the below cases does not work for me.
> >
> > I am using JBoss with Tomcat 3.2.3.
> >
> >
> > 1) Problem with dispatching from Servlet to JSP.
> >
> > In my Servlet I redirect/dispatch to a JSP template. This works
fine,
> > when running the Servlet without Cactus. But when running my Cactus
> test
> > case I get below error every time. This is the code that fails.
> >
> >
> >         ServletContext servletContext  = getServletContext();
> >
> > 	javax.servlet.RequestDispatcher requestDispatcher  =
> > 	    servletContext.getNamedDispatcher( template );
> > 	requestDispatcher.forward( req, res );  <------- This goes
> wrong.
> >
> > I have initialized the servlet context first in the Cactus test
case:
> > 	servlet.init(config);
> >
> > This is the error I get:
> >
> > java.lang.NullPointerException
> > at
> >
>
org.apache.cactus.server.RequestDispatcherWrapper.forward(RequestDispatc
> he
> > rWrapper.java:98)
> > at com.inceptor.rt.Servlet.dispatchError(Servlet.java:164)
> 
> [snip]
> 
> I'm currently looking into this. There is indeed a bug in Cactus, in
> that the Cactus-wrapped getNamedDispatcher() does not return null if
the
> servlet (named "template" in your example) is not found. Instead
Cactus
> returns a request dispatcher wrapper. I have corrected this. It means
> that now your test will still return a NullPointerException but in
> _your_ code rather than in Cactus code. The null pointer will happen
on
> the line :
> 
> requestDispatcher.forward( req, res );
> 
> This is normal, it is part of the spec. The spec says to return null
if
> the named servlet cannot be found. Make sure your "template" is in the
> same context and has an entry in web.xml.
> 
> Note 1 : I've added a test case in Cactus so that this problem does
not
> happen again. Here it is :
> 
>     public void testGetRequestDispatcherFromNamedDispatcher()
>         throws ServletException, IOException
>     {
>         RequestDispatcher rd =
>             config.getServletContext().getNamedDispatcher("TestJsp");
>         rd.forward(request, response);
>     }
> 
>     public void endGetRequestDispatcherFromNamedDispatcher(WebResponse
> theResponse)
>         throws IOException
>     {
>         String result = theResponse.getText();
>         assertTrue("Page not found, got [" + result + "]",
>             result.indexOf("Hello !") > 0);
>     }
> 
> "TestJsp" is defined in web.xml as :
> 
>     <servlet>
>         <servlet-name>TestJsp</servlet-name>
>         <jsp-file>/test/test.jsp</jsp-file>
>     </servlet>
> 
> Note 2 : I've tried it with Tomcat 4.x and Tomcat 3.2.4 and it works
> fine. However, it fails on Tomcat 3.3.x ... I'll submit a bug report
to
> them as it looks like a bug.
> 

FYI, I have reported the bug to Tomcat 3 dev team, they have fixed it in
CVS and it will be released as Tomcat 3.3.1. The GUMP of yesterday
worked fine with Tomcat 3 so it seems to be working
(http://jakarta.apache.org/builds/gump/latest/jakarta-cactus-22.html).

Thanks

[snip]

-Vincent





--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message