cancel
Showing results for 
Search instead for 
Did you mean: 

Client computer name

Former Member
0 Kudos

Hi.

I have to determine the client computer name from my wdp app, i'm using the InetAddress class from the JAVA's API as follows:

HttpServletRequest req = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();

String dirIP = req.getRemoteAddr();

byte[] hostAdd = new byte[4];

StringTokenizer st = new StringTokenizer(dirIP);

int i = 0;

while(st.hasMoreTokens()){

hostAdd<i> = (byte)(Integer.parseInt(st.nextToken(".")));

i++;

}

try{

InetAddress ia = InetAddress.getByAddress(hostAdd);

String host = ia.getHostName();

} catch(Exception e){}

It makes that the app works slowly and in some cases return the IP not the name.

I also try this:

HttpServletRequest req = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();

String host = req.getRemoteHost();

But i get the IP not the name.

Am i in the correct way?

How can i determine the user computer name?

Best Regards.

Gregory.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Gregory,

You will never get acurate result with this approach.

Consider clients behind proxy/firewall.

Consider browsers that does not sent this name in HTTP headers.

Anyway, what you force your code to do is DNS lookup. Hence it runs slowly.

My advise -- just don't. What is your original requirement? I cann't believe that you need remote computer name just to have remote computer name

VS

VS