建议在jsp中用java实现,javascript估计是有难度。

解决方案 »

  1.   

    在基于TCP/IP互联时,经常会需要查询自己主机的IP地址和www服务器的IP地址。虽然,我们可以使用IPCONFIG和PING等命令进行IP地址查询,但是如果在应用程序或APPLET中使用此命令会破坏我们应用程序界面,使其很不雅观。但使用JAVA 做一个简单的程序可以直接查询自己主机的IP地址和www服务器的IP地址。 
    如下:
    // 文件名为 NetTool.java 
    (注意:在JAVA 语言中大小写敏感)
    import java.net.*;
    public class NetTool{ InetAddress myIPaddress=null;
    InetAddress myServer=null;
    public static void main( String args[]){
    NetTool mytool;
    mytool=new NetTool();
    System.out.println(\"Your host IP is: \" + mytool.getMyIP());
    System.out.println(\"The Server IP is :\" 
    +mytool.getServerIP());
    }
    //取得LOCALHOST的IP地址
    public InetAddress getMyIP() {
    try { myIPaddress=InetAddress.getLocalHost();} 
    catch (UnknownHostException e) {}
    return (myIPaddress); } 
    //取得 www.abc.com 的IP地址
    public InetAddress getServerIP(){ 
    try {myServer=InetAddress.getByName( 
    \"www.abc.com\");}
    catch (UnknownHostException e) {} 
    return (myServer); } } 
    由于JAVA语言的跨平台特性,以上程序编译后可直接在任何装有JVM系统的机器上运行。以上程序旨在抛砖引玉,读者可将上述代码稍加变换转化成APPLET加到你的homepage中,或将地址查询结果写到一个文件中去,建立自己本地的hosts文件。
      

  2.   

    再jsp中可以用
    <%
    String IpVar;
    InetAddress myIPaddress=null;
    try {
    myIPaddress=InetAddress.getByName("www.abc.com");
    IpVar = (String)myIPaddress;

    catch (UnknownHostException e) {}
    %>
      

  3.   

    http://community.csdn.net/Expert/topic/3440/3440117.xml?temp=.7996942
      

  4.   

    javascript 每法对IP协议进行编程,不能编写ICMP报文
      

  5.   

    import java.net.*;
    public class NetTool{ InetAddress myIPaddress=null;
    InetAddress myServer=null;
    public static void main( String args[]){
    NetTool mytool;
    mytool=new NetTool();
    System.out.println(\"Your host IP is: \" + mytool.getMyIP());
    System.out.println(\"The Server IP is :\" 
    +mytool.getServerIP());
    }
    //取得LOCALHOST的IP地址
    public InetAddress getMyIP() {
    try { myIPaddress=InetAddress.getLocalHost();} 
    catch (UnknownHostException e) {}
    return (myIPaddress); } 
    //取得 www.abc.com 的IP地址
    public InetAddress getServerIP(){ 
    try {myServer=InetAddress.getByName( 
    \"www.abc.com\");}
    catch (UnknownHostException e) {} 
    return (myServer); } } 
    我截取了上面的代码进行测试后果然那可以,那你就可以用上面的代码编译成 Class 以后在 Jsp中用<use:javaBean  id=""   scope"page"  class="包名"/>  这样你就可以轻松地在jsp 中调用了 。