954,113 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

JSP - Ping a Port

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.

AshtonHogan
Posting Whiz in Training
210 posts since Jul 2009
Reputation Points: 7
Solved Threads: 1
 

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

AshtonHogan
Posting Whiz in Training
210 posts since Jul 2009
Reputation Points: 7
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: