Yis-Shi Lee wrote:

> Below is the code I used to call jsp but it didn't work with Jrun2.3.3.
> How to resolve this question?
>
> req.setAttribute("userInfo",rs);
>       RequestDispatcher dispatcher;
>       dispatcher = getServletContext().getRequestDispatcher("SearchResult.jsp");
>       dispatcher.include(req, res);
> ----
> error message
>
> <head><title>JRun Servlet Error</title></head>
> <h1>500 Internal Server Error</h1><body>
> <PRE>
> <B>com.livesoftware.jsp.JSPServlet:</B>
>
> java.lang.NullPointerException
> </PRE>
> <p>
> </body>
>
> Thanks for help
>

There are two issues:

* According to the API documentation, the argument to getRequestDispatcher
  needs to start with a slash, and be interpreted as relative to the servlet
  context your app is running in.  Try this instead:

    dispatcher = getServletContext().getRequestDispatcher("/SearchResult.jsp");

* According to the API documentation, getRequestDispatcher() is allowed to
  return null.  However, your code does not check for this case, so the NPE
  is your code's fault.  Try this instead:

    if (dispatcher != null) {
        dispatcher.include(req, res);
    } else {
        ... report the error, or ignore, as appropriate ...
    }

I don't use JRun, so there might be other JRun specific issues as well, but you need
to address these two.

Craig McClanahan


>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to