title: Requestdispatcher in servlets: forward method not preserving request attribute
body: <p>This is my prog1:</p>
  
  <pre><code>public class DispatcherSample extends HttpServlet
  {
      public void service(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
      {
          PrintWriter out=response.getWriter();
          out.println("we are in first servlet.");
          request.setAttribute("name","sanjay");
          RequestDispatcher rd=request.getRequestDispatcher("/ss");
          rd.forward(request,response);
          }
  }
  </code></pre>
  
  <p>This is my prog2:</p>
  
  <pre><code>public class SecondServlet extends HttpServlet
  {
      public void service(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
      {
          PrintWriter out=response.getWriter();
          out.println("we are in second servlet.");
          request.setAttribute("surname","korlepara");
          //RequestDispatcher rd=request.getRequestDispatcher("/ts");
          //rd.forward(request,response);
          out.println(request.getAttribute("name"));
          out.println(request.getAttribute("surname"));
      }
  }   
  </code></pre>
  
  <p>OUTPUT is:
  we are in second servlet.
  null
  korlepara</p>
  
  <p>Problem is: unable to retrieve attribute name</p>