Skip to Content
avatar image
Former Member

System identification

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jul 22, 2009 at 07:58 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 22, 2009 at 08:03 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 22, 2009 at 08:46 AM

    Hi,

    use this code,

    String IP = req.getRemoteAddr();

    Regards,

    sunaina Reddy T

    Add comment
    10|10000 characters needed characters exceeded