tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: Problem with getRequestDispatcher
Date Tue, 30 May 2000 21:10:41 GMT
Mike Karl wrote:

> I am trying to forward the request from a Servlet to a JSP using
> getRequestDispatcher.  Tomcat is giving me an error when I try to do
> this:
>
> ServletContext sc = getServletContext();
> RequestDispatcher rd = sc.getRequestDispatcher("../CustReg.jsp");
> rd.forward(req, res);
>
> I get:
> java.lang.NullPointerException
>         at CustReg.doPost(CustReg.java:65)

This is happening because getRequestDispatcher() is returning a null.  The reason for that
is you are
specifying an invalid argument -- the path must begin with a slash and be relative to the
context root.

If you want to use a path like this ("../CustReg.jsp") that is relative to the current request,
call

    request.getRequestDispatcher()

instead.

Craig McClanahan



Mime
View raw message