cancel
Showing results for 
Search instead for 
Did you mean: 

System identification

Former Member
0 Kudos

Hi all,

I need to initialize an IP address in my application with different values accordingly to system environment where I run my application(dev, qa, prod).How can I do this?

Thanks,

Michael Beilin

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

use this code,

String IP = req.getRemoteAddr();

Regards,

sunaina Reddy T

Former Member
0 Kudos

Hi,

try

{

String str = WDURLGenerator.getAbsoluteWebResourceURL("/");

if (str != null)

{

URL url = new URL(str);

result =

url.getProtocol()

+ "://"

+ url.getHost()

+ ":"

+ url.getPort();

}

}

catch (Exception e)

{

// TODO Auto-generated catch block

e.printStackTrace();

}

The alternative way to achieve this is to use IWDRequest.

IWDRequest req=WDProtocolAdapter.getProtocolAdapter().getRequestObject();

wdComponentAPI.getMessageManager().reportSuccess(req.getServerName());

wdComponentAPI.getMessageManager().reportSuccess(""+req.getServerPort());

Regards,

Srikanth

Edited by: Srikanth Thatipally on Jul 22, 2009 10:04 AM

Edited by: Srikanth Thatipally on Jul 22, 2009 10:08 AM

Former Member
0 Kudos

Hi Michael,

Here's how you can get the hostname :

import com.sap.tc.webdynpro.services.task.TaskBinder;

String hostname = TaskBinder.getCurrentTask().getProtocolAdapter().getServerName();

Or you could do something like this to get the IP address :

InetAddress inetaddr = InetAddress.getLocalHost();
String ipaddr = inetaddr.getHostAddress();

Regards,

Pierre