title: How to refresh the jsp page when dispatcher is used from the servlet?
body: <p>I'm using Eclipse JUNO IDE and tomcat 7.0.</p>
  
  <p>I have a web application. In the application I have:</p>
  
  <ol>
  <li><p>Servlet</p></li>
  <li><p>JSP pages</p></li>
  <li><p>HTML - the main page.</p></li>
  </ol>
  
  <p>In the main page I have a form which redirect to the servlet (because I need to get data from Server) when a submit-button is clicked and the servlet redirect to the match jsp page. 
  Now when I'm refreshing the jsp page, the servlet get NULL in the request. so my question 
  is how to resubmitting? because I want to display the new data from the server.</p>
  
  <p>NOTE: The Servlet talks to the Server with sockets, so when user is pressing on some submit-button, the request redirect to the servlet and the servlet redirect the request
  to the server to get the required data. Now when the servlet recieved the data, it's transporting the data to the jsp page, and the jsp page display it as html</p>
  
  <pre><code>    if (request.getParameter("submit").equals("Show Taxis at Driving"))
      {
             requests.add("driving");
             to_server.writeObject(requests);
             to_server.flush();
             requests.removeAllElements();
  
             try{
                 driving = (Vector)from_server.readObject();
                 request.setAttribute("driving", driving);
                 //request.getRequestDispatcher("/WEB-INF/driving_page.jsp").forward(request, response);
                 RequestDispatcher disp = getServletContext().getRequestDispatcher("/WEB-INF/driving_page.jsp");
                 disp.forward(request, response);
             }catch(ClassNotFoundException e)
             {
                 e.printStackTrace();
             }
      }
      else if (request.getParameter("submit").equals("Add Passenger to Taxi"))
      {
          requests.add("taxis");
          requests.add("passengers");
          to_server.writeObject(requests);
          to_server.flush();
          requests.removeAllElements();
  
          try {
              taxis_waiting  = (Vector)from_server.readObject();
              passengers = (Vector)from_server.readObject();
              request.setAttribute("taxis", taxis_waiting);
              request.setAttribute("passengers", passengers);
              request.getRequestDispatcher("/WEB-INF/add_passenger_to_taxi.jsp").forward(request, response);
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
              request.getRequestDispatcher("error_page.jsp").forward(request, response);      
          }
      }
  </code></pre>