在applet中用调用getcodeBase().gethost()即可

解决方案 »

  1.   

    和我最初的想法是一样的,可是如果你的url is http://ddd/index.html
    该方法会返回ddd,ddd is not IP.
    如果你在其他机器上运行InetAddress.getByName("ddd")只会返回"127.0.0.1"(这是由于JAVA的安全限制)
      

  2.   

    用java.net.InetAddress类就行了,例子代码如下:String szHost = TheHostName, szIP = null;
    InetAddress oIP = null;
    if( szHost != null)
      oIP = InetAddress.getByName(szHost);
    if(oIP != null)
      szIP = oIP.getHostAddress());比如,szHost = "263.net" 时,szIP = "202.96.44.43"
    szHost = "www.csdn.net", szIP = "210.77.155.27"Enjoy it!
      

  3.   

    yes! 这是对于应用程序是这样,对于Applet不是的!
      

  4.   

    java我就不晓得了,用asp还是蛮方便,cgi也不错