title: Synchronize Request and Response in HttpClient Class
body: <p>I am trying to make login validation in using httpClient and getting infinite loop on server side.More explanation will be after code. here is my server side code</p>
  
  <pre><code>    public void doPost(HttpServletRequest req, HttpServletResponse resp)
      while(true){    
          String user_name = req.getParameter("username");
          String password = req.getParameter("password");
          System.out.println("User name and password is "+user_name +"   paswword is "+password);
          resp.setContentType("text/plain");
          PrintWriter writer = resp.getWriter();
          if(user_name.equalsIgnoreCase("haseeb")){
              System.out.println("valid user name");
              writer.write("welcome");
              //writer.flush();
              break;
          }
          else{
              writer.write("unknown User");
              System.out.println("unknown user name");
              writer.flush();
              continue;
          }
  
      }//End of while loop
  
  }   //End of doPost Method
  </code></pre>
  
  <p>from client side i am trying to login, if login is invalid the server will return "unknownUser" after that client will send again request to login if login is valid the loop will break. on server side i am getting infinite loop and server is processing on first request parameters again and again and again....!!! If any one want i can post my client side code for further assistance, you can ask for it on comments section..Thankyou</p>