我也问一个Java问题(100分)

C

cAkk

Unregistered / Unconfirmed
GUEST, unregistred user!
在java applet里面怎样得到调用该applet的机器host/ip?
比如说,我在100.100.100.1的机器上面有一个applet,
现在我在100.100.100.2的机器上引用该机器上的applet,
怎样得到100.100.100.2这个地址?
 
Y

yysun

Unregistered / Unconfirmed
GUEST, unregistred user!
Applet.getCodeBase().getHost().getHostAddress();
or
java.net.InetAddress.getLocalHost().getHostName();
If you get result like "localhost" and the which is 127.0.0.1, this
is a deliberate security feature in the JDK. Untrusted applets will
not be given the real host name.
(http://www.javasoft.com/products/plugin/1.2/plugin.faq.html#work)

 
E

Emperor

Unregistered / Unconfirmed
GUEST, unregistred user!
贊成ysun的方法
 
B

bethouvnlue

Unregistered / Unconfirmed
GUEST, unregistred user!
遇到问题的时候应该先到java.sun.com去查一查
 
C

cAkk

Unregistered / Unconfirmed
GUEST, unregistred user!
>>遇到问题的时候应该先到java.sun.com去查一查
没时间呀!我已经忙的没时间学习了.
 
C

cAkk

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 

水中月

Unregistered / Unconfirmed
GUEST, unregistred user!
顶部