title: Storing and Retrieving Values In Request Scope
body: <p>I have made a jsp page for registering members, when registering if the person forgets to fill any field in the form , a error message is displayed in another page. </p>
  
  <p>Inorder to achieve this i have used 3 servlets , First servlet to get the values from the jsp page and pass in to the second servlet which checks whether there are any fields empty , if yes , it returns back a message to the first servlet , which then passes the message to a third servlet to display the error message to the user. </p>
  
  <p>My problem is the message doesn't get passed from first servlet to the third servlet. It just returns null.</p>
  
  <p>Here is what i have done :</p>
  
  <p>First Servlet Code : </p>
  
  <pre><code>        String firstName=request.getParameter("firstName");
          String lastName=request.getParameter("lastName");
  
          String userName=request.getParameter("userName");
          String password=request.getParameter("password");
  
     Message message=Authenticator.registerUser(firstName, lastName, userName,"Student", password);
     HttpSession mySession=request.getSession();
     RequestDispatcher failMessageDispatcher=                   request.getRequestDispatcher("/ErrorController");
  
     String message1=message.getMessage(); //gets the message to a variable
     request.setAttribute("message", message1);  // puts the variable in to the request scope 
  
     out.println(message1);
     if(message.getStatus().equals("0"))
     {
  
         failMessageDispatcher.forward(request, response); //forwards to the third servlet for displaying
  
     }
  </code></pre>
  
  <p>Third Servlet Code :</p>
  
  <pre><code>       String message= request.getParameter("message"); //get the message from the request scope
         out.println(message); //display the message
  </code></pre>
  
  <p>I know its a problem in the request scope, because if put it in to a session scope , it works, but the thing is i want to use the request scope for this job. How can i make this work?</p>
  
  <p>Thank you for your time.</p>