JSP, JAVA로 ping 체크하기

7. 프로그래밍 2014. 10. 23. 15:34

 

 

<%@ page contentType="text/html; charset=EUC_KR" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.InetAddress" %>
<%

String keyword = request.getParameter("keyword");  // 조회하려는 ip를 파라메터로 받아서 처리

try {
 InetAddress inetIp = InetAddress.getByName(keyword); //장비들에 대한 IP기입
 boolean result =  inetIp.isReachable(2000); //isReachable 메소드는 JDK1.5버전부터 지원하므로 하위버전에는 오류남.

 if (result) {
  out.println(keyword + " ping OK");
 } else {
  out.println(keyword + " ping Failed");
 }

} catch (Exception e) {
 e.printStackTrace();
}
%>

 

ajax로 값을 받아서 콜백체크를 하던.. 뭐 어떻게 구현을 하던 프로그래머의 입맛에 맛게 구성하면 될듯.