kwai kwai wrote:

> Hi,
>
> I had 2 programs which are exactly the same in the way
> they get the Hostname and Ip address.
>
> The one which i ran from command line and other was
> run as servlet.
> Both used the following code to get the ip address,
>       java.net.InetAddress localHost =
> java.net.InetAddress.getLocalHost();
>       ipAddress = localHost.getHostAddress()
>
> When run from command line,
>      localHost=mypc/125.25.20.1
>      ipaddress = 125.25.20.1
>
> When run as servlet,
>      localHost=mypc/127.0.0.1
>      ipaddres= 127.0.0.1  (loop back address)
>
> Environment: Windows 2000, Apache
> This was working on my solaris environment...
>
> I saw in one of the doc pages that the java libs
> dont return the actual ip address to an untrusted
> applet..I am not using an applet.
>
> Could it be anything to do with the dns setup ?
> my nslookup gives an error, but my "hosts" file
> has the proper ipaddress for my hostname..
> But if it was DNS problem, why do i get IP address
> from command line ?
>
> Thanks in advance
> Vijay
> [...]

Hi :-)  I can get correct InetAddress with:
         InetAddress.getLocalHost()

I test it in:  jsdk2.1 + jdk1.3

I just suggest you notice that if the enviroment(for example,
the CLASSPATH, security-policy?, ...) is similar  when you
run your 2 programs.


Bo
Jan.12, 2001

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to