944,088 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 2559
  • JSP RSS
Oct 29th, 2009
0

JSP - Ping a Port

Expand Post »
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.
Similar Threads
Reputation Points: 7
Solved Threads: 1
Posting Whiz in Training
AshtonHogan is offline Offline
209 posts
since Jul 2009
Oct 29th, 2009
1
Re: JSP - Ping a Port
I found code that you can use in a servlet. Something like this:

JSP Syntax (Toggle Plain Text)
  1. try {
  2. String ip = "127.0.0.1";
  3. Process p = Runtime.getRuntime().exec("ping -n 1 " + ip);
  4. int status = p.waitFor();
  5. System.out.println(ip + " is " + (status == 0 ? "alive" : "dead"));
  6. }//end try
  7. catch (Throwable t) {
  8. t.getMessage();
  9. }

Thanks anyway! -Hope this helps someone else...
-Ashton
Last edited by AshtonHogan; Oct 29th, 2009 at 2:48 pm.
Reputation Points: 7
Solved Threads: 1
Posting Whiz in Training
AshtonHogan is offline Offline
209 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: (newline) problem with in text file
Next Thread in JSP Forum Timeline: XML parsing in JSP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC