Link to home
Start Free TrialLog in
Avatar of rotem_fo
rotem_fo

asked on

InetAddress and Java 1.3

Hi,
I am developing a Applet and i want to get the host name of the computer i an running the applet on.
When i use JApplet.getCodeBase().getHost() I receive localhost instead of the server name.
When i use InetAddress.getLocalHost().getHostName() i get the same.
Any ideas ???
Thanx.
Avatar of antons061400
antons061400

probably you download that applet from your PC. (a web server take it from there)
Avatar of Mick Barry
Firstly the two thing you are try are different:

JApplet.getCodeBase().getHost()
Returns the host of the server where the applet was loaded.

InetAddress.getLocalHost().getHostName()
Returns the hostname of the client. This information is not accessible to unsigned applets and thus it is returning 'localhost' You need to sign the applet to be able to find the local hostname.
Avatar of rotem_fo

ASKER

Hi,
I used getCodeBase().getHost() .
Whenever i type the server's name in the address bar (in the internet explorer) i receive the machine name, if i type the ip address the getCodeBase().getHost() returns the ip entered in the address bar.
I am lost :(

R.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
rotem_fo:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between objects and dviji

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer