Applet如何取得服务器的IP地址? 如题. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); } } 这个我知道,我是想知道在不知道服务器的情况下,也就是写完这个applet后,在不用修改任何代码,直接使用该applet就可以获得服务器的ip地址. jsp网页里可以得到服务器ip地址,然后以参数形式传给applet 楼上的对, 传参.. Applet本身没有知觉, 呵呵 webOffice控件的使用 用控件打开的文档 可以进行修改再保存么?? 有经验的请进 非常感谢!! 为什么我的frame不好用 求解决ssh整合出现的异常 关于java 实现mySQL数据备份、还原的问题 关于web打印组件ScriptX.cab的问题,急。 请问《Servlet与JSP核心编程》第二卷叫什么名字? jsp跳转疑问 哪位高手做过webgis和j2ee结合的项目请进! 请问有关动态生成表格中怎样插入单选按扭(radiobutton) 在另一驱动盘中的JSP如何设置虚拟目录 我想把TOMCAT的端口号改成80 可是老出错!!!! WEB 程序的 分页技术
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);
} }