jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwai...@earthlink.net
Subject RE: Newbie question re forwarding
Date Tue, 10 Jun 2003 19:43:26 GMT
Hi Vincent, thanks for your help.

No, I had not been calling WebRequest.setURL(), so that's part of the 
battle.  :-)

But, after calling WebRequest.setURL() with the first three arguments 
non-null, I'm still seeing the NPE.  I haven't checked-out your fix from 
CVS yet, so I'll try that next.  Just letting you know of the results so 
far.

> PS: Are you based in Hong Kong (just a wild guess from your email name)?
:-)

No, San Francisco.  Next best thing, LOL.  Great guess though!

--Mark





"Vincent Massol" <vmassol@pivolis.com>
06/07/2003 04:37 AM

 
        To:     "'Cactus Users List'" <cactus-user@jakarta.apache.org>
        cc:     <gwailoh@earthlink.net>
        Subject:        RE: Newbie question re forwarding


Hi Mark,

In order to help you I need to know if you are calling the
WebRequest.setURL() method for this test in your beginXX() method?

What happens is that, when you are using the relative form of
request.getRequestDispatcher(), Cactus computes the full path from the
relative path. This is computed by getting the Servlet Path. If you have
called setURL() then you have set what the servlet path should be (third
argument of the setURL()). So if you have put the value null if will
currently fail.

I have provided a fix in CVS: Cactus now verifies that the parameters to
setURL() are valid and if you use a null value, then Cactus will use the
value from the request sent to the Cactus Redirector.

The other possibility is that your servlet engine returns a null value
for getServletPath() but that would be strange as it is against the
specifications...

Note that you can also use the absolute form:
request.getRequestDispatcher("/foo.jsp")
which should work even with Cactus 1.4.1.

Thanks
-Vincent

PS: Are you based in Hong Kong (just a wild guess from your email name)?
:-)

> -----Original Message-----
> From: Mark Phillips [mailto:gwailoh@earthlink.net]
> Sent: 29 May 2003 22:08
> To: cactus-user@jakarta.apache.org
> Subject: Newbie question re forwarding
> 
> Hello all:
> 
> I'm using Cactus to test a servlet which includes a call to
> request.getRequestDispatcher("pageName").forward(request, response).
In
> production the servlet works correctly.  However my Cactus test fails
with
> a NullPointerException, leading me to believe I'm failing to set up
some
> part of the Cactus environment which Cactus expects.
> 
> In testing I've noticed that this call succeeds inside a testXXX
method:
> 
> 
>
assertNotNull(config.getServletContext().getRequestDispatcher("/foo.jsp"
))
> ;
> 
> While this call fails with NPE inside an otherwise identical testXXX
> method:
> 
>     assertNotNull(request.getRequestDispatcher("foo.jsp"));
> 
> The two testXXX methods do include calls to servlet.init(config).
> 
> Here's what looks like the relevant portion of the Cactus stack trace:
> 
> null
> 
> java.lang.NullPointerException
> at
>
org.apache.cactus.server.AbstractHttpServletRequestWrapper.catPath(Abstr
ac
>
tHttpServletRequestWrapper.java;org/apache/cactus/util/log/LogAspect.aj(
1k
> ):399)
> at
>
org.apache.cactus.server.AbstractHttpServletRequestWrapper.dispatch43_ge
tR
>
equestDispatcher(AbstractHttpServletRequestWrapper.java;org/apache/cactu
s/
> util/log/LogAspect.aj(1k):369)
> at
>
org.apache.cactus.server.AbstractHttpServletRequestWrapper.around43_getR
eq
>
uestDispatcher(AbstractHttpServletRequestWrapper.java;org/apache/cactus/
ut
> il/log/LogAspect.aj(1k):1218)
> at
>
org.apache.cactus.server.AbstractHttpServletRequestWrapper.getRequestDis
pa
>
tcher(AbstractHttpServletRequestWrapper.java;org/apache/cactus/util/log/
Lo
> gAspect.aj(1k):343)
> 
> Is there some step I need to take so that
request.getRequestDispatcher()
> will suceed inside testXXX?
> 
> Thanks!
> 
> --Mark
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org





Mime
View raw message