Member Avatar for feoperro

Hi,

I would just like to know if it's possible to ping a certain port from a jsp page.
For example:

If I had a Apache_Status.jsp on my machine and I wanted to ping it on another machine at:
123.456.78.90:8080

And I had a Glassfish_Status.jsp on my machine and I wanted to ping it on another machine at:
321.654.87.09:8484

Would this be possible?

Thanks,
-Ashton.

Member Avatar for feoperro

I found code that you can use in a servlet. Something like this:

try {
            String ip = "127.0.0.1";
            Process p = Runtime.getRuntime().exec("ping -n 1 " + ip);
            int status = p.waitFor();
            System.out.println(ip + " is " + (status == 0 ? "alive" : "dead"));
        }//end try
        catch (Throwable t) {
            t.getMessage();
        }

Thanks anyway! -Hope this helps someone else...
-Ashton

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.