Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

PingServlet  RSS feed

 
jesse harris
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does anyone know how to ping from a servlet?
thanks in advance
Jesse
 
Brian Glodde
Ranch Hand
Posts: 171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps you could use an existing package such as PortPing and get the results you need.
Here's a 2nd link that might be more helpful.
[ May 22, 2002: Message edited by: Brian Glodde ]
 
Sita Kodali
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might try this in a servlet
#################################################################
import java.io.*;
public class Execute
{
public static void main(String [] args)
{
try {
String params[] = { "ping","www.yahoo.com"};
Process pinger = Runtime.getRuntime().exec(params);
BufferedReader reader = new BufferedReader(new
InputStreamReader(pinger.getInputStream()));
String lineRead = null;
while((lineRead = reader.readLine()) != null)
{
System.out.println(lineRead); }
}catch(Exception e)
{
e.printStackTrace();
}
}
}
###############################################
If you want to check if a particular port is available, you may try Socket way
HTH
--
Venkat
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!