JSP - Ping a Port

Reply

Join Date: Jul 2009
Posts: 81
Reputation: AshtonHogan is an unknown quantity at this point 
Solved Threads: 1
AshtonHogan AshtonHogan is offline Offline
Junior Poster in Training

JSP - Ping a Port

 
0
  #1
26 Days Ago
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 81
Reputation: AshtonHogan is an unknown quantity at this point 
Solved Threads: 1
AshtonHogan AshtonHogan is offline Offline
Junior Poster in Training
 
1
  #2
26 Days Ago
I found code that you can use in a servlet. Something like this:

  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; 26 Days Ago at 2:48 pm.
Reply With Quote Quick reply to this message  
Reply

Tags
apache, glassfish, jsp, network, ping

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC