title: Real-time ping result using ajax
body: <p>I'm trying to create a web application which can display the results of a ping command real-time. I'm using JSP in the backend. I'm actually getting the result correctly. But the problem is, the result is not displayed in real-time. The application processes the ping command and dumps the result all at once. What I  need is that, the application has to display the result line after line as and when a line of result is obtained.</p>
  
  <p>Here is my code</p>
  
  <pre><code>String ip = request.getParameter("ipaddress");
  
  String pingCmd = "ping -c 3 " + ip;
  
  Runtime runtime = Runtime.getRuntime();
  
  Process p = runtime.exec(pingCmd);
  
  BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
  String inputLine;
  
  while ((inputLine = in.readLine()) != null)
  {
      out.println(inputLine + "&lt;br /&gt;");
  }
  in.close();
  </code></pre>
  
  <p>What is the change I need to make in this code.</p>
  
  <p>Regards</p>
  
  <p>Sunil Kumar B M</p>