1

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.

Here is my 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 + "<br />");
}
in.close();

What is the change I need to make in this code.

Regards

Sunil Kumar B M

mowwwalker
  • 16,634
  • 25
  • 104
  • 157
Sunil Kumar B M
  • 2,735
  • 1
  • 24
  • 31

1 Answers1

0

You can do this with a comet servlet. For tomcat 6: http://tomcat.apache.org/tomcat-6.0-doc/aio.html

Maurice Perry
  • 32,610
  • 9
  • 70
  • 97