on 04-04-2006 5:47 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.