1 Reply Latest reply on Mar 3, 2005 4:09 AM by Geoff Seel

    Using RequestDispatcher, NullPointerException

    Abhishek Asthana Newbie

      Hi,
      I am using RequestDispatcher to forward data from servlet to JSP.

      try{
       HttpSession session=request.getSession(true);
       session.setAttribute("LoginMessage",loginMessage);
       RequestDispatcher rd=request.getRequestDispatcher("../LoginMessage.jsp");
       rd.forward(request,response);
       }catch(Exception e){
       System.out.println("error2 in doGet "+e);
       e.printStackTrace();
       out.println("error2 in doGet");
      


      I am working in JBoss 3.2.1, When I run the servlet in browser I get this error:
      21:02:02,013 INFO [STDOUT] error2 in doGet java.lang.NullPointerException
      21:02:02,013 ERROR [STDERR] java.lang.NullPointerException
      21:02:02,013 ERROR [STDERR] at au.com.tusc.servlet.MyServlet.doPost(MyServlet.java:69)
      21:02:02,013 ERROR [STDERR] at au.com.tusc.servlet.MyServlet.doGet(MyServlet.java:80)
      21:02:02,013 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
      21:02:02,013 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      21:02:02,013 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
      21:02:02,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
      21:02:02,013 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1714)
      21:02:02,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1664)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpServer.service(HttpServer.java:863)
      21:02:02,013 ERROR [STDERR] at org.jboss.jetty.Jetty.service(Jetty.java:460)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.service(HttpConnection.java:775)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
      21:02:02,013 ERROR [STDERR] at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
      21:02:02,013 ERROR [STDERR] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
      21:02:02,013 ERROR [STDERR] at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
      
      


      What may be the problem? why is rd null? Please help.
      Thanks,
      Abhishek