hi,

i am trying to implement 2 servlets in a bundle using the httpservice. there is 
the code :
the first servlet:
public class FirstServlet extends HttpServlet {
                                                                     
   protected void doGet(HttpServletRequest req, HttpServletResponse res)
                                                                 
           throws ServletException, IOException {
                                                                             
       req.setAttribute("name", "sana ");
       RequestDispatcher dispat = req.getRequestDispatcher("/servlet2");
       dispatcher.forward(req,res);
                   
                                       
   }
                                               
}

the second servlet:

                     public class SecondServlet extends HttpServlet {
                       protected void doGet(HttpServletRequest req, 
HttpServletResponse res)
                                                                                                        
 throws ServletException, IOException {
                         res.setContentType("text/plain");
                         PrintWriter out = res.getWriter();
                                                   
                                                                                           
  
                         out.println(req.getAttribute("name"));
                                                                                                                           
  
                       }
                     }


but i get an error : null pointer exception in my webbrowser ( the problem is 
in line  dispatcher.forward(req,res); )


Can you help me ?

thanks in advance

Asma



      

Reply via email to