cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the pc name or IP

anibal_alonso
Explorer
0 Kudos

Hi, I need to know if there is any way to get the pc name in a Web Dynpro application or ip address of the computer running the application WD, ie I need the name or ip of the client, not server, thanks, regards

Accepted Solutions (1)

Accepted Solutions (1)

pradeep_kumar5
Active Participant
0 Kudos

Hi,

use this code;

InetAddress thisIp =InetAddress.getLocalHost();

String IPAddress = thisIp.getHostAddress();

and import this package

import java.net.*;

Regards,

Pradeep Kumar G

anibal_alonso
Explorer
0 Kudos

Hi,

with that I get to see the name and server ip, not the client pc. I need this last...

Qualiture
Active Contributor
0 Kudos

Hi Anibal,

You can use this code snippet:

String clientHostAddress= WDProtocolAdapter.getProtocolAdapter().getRequestObject().getClientHostAddress();

Best regards,

Robin van het Hof

anibal_alonso
Explorer
0 Kudos

Thank you very much, that solved my problem. One question, with this code:

String clientName = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getClientHostName();

I get the ip and not the customer's name, why?

Qualiture
Active Contributor
0 Kudos

Hi Anibal,

Glad it worked.

With the code snippet you provided, you will only get the client's hostname (or ip address, if hostname cannot be determined)

If you need to determine the current user, use the following code:

try {
	IWDClientUser wdUser = WDClientUser.getCurrentUser(); 
	IUser         user   = wdUser.getSAPUser();
} catch (WDUMException e) {
	// do your error handling here
}
return user;

anibal_alonso
Explorer
0 Kudos

Thanks Robin, I know this code!

Answers (0)