cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Application Server Environment Information?

Former Member
0 Kudos

Hi,

How to get Application server Environment information into my application.

for example my application need to behave differently in DEV, TEST,PROD with values defined according to the environment

where it is deployed.

Please help me out from this.

thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

pravesh_verma
Active Contributor
0 Kudos

Hi,

Check these API's of WDProtocolAdapter.


String serverName = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getServerName();
int serverport = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getServerPort();
	  
String hostAddress = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getClientHostAddress();
String hostName = WDProtocolAdapter.getProtocolAdapter().getRequestObject().getClientHostName();

Once you have the name of the server with yiu then you can decide upon the code logic according to your requirement.

I hope this helps you!! Please revert back in case you need nay further information.

Thanks and Regards,

Pravesh

Former Member
0 Kudos

Thanks Pravesh,

The code you have given is working fine. but i want a little specific about the server where iam going to deploy.

Like , is there any parameter will be declared in the server which will get whether it is a DEV server or TEST server or PROD server.

What iam getting from the code you have given is like below

Server Name:_xdev.sap.www.abcd.com_

thanks

Former Member
0 Kudos

Hi,

If your WebDynpro for Java Application is running in an iView, you can always add an application parameter like RUN_SYS=DEV in the iView attributes and read this parameter in your application.


IWDRequest req = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
	
String mySys = req.getParameter("RUN_SYS");

if (mySys.equalsIgnoreCase("DEV")) {

/* Do your stuff */
}

Hope this helps a little.

Regards,

Alain

Former Member
0 Kudos

I am getting null for the "RUN_SYS" parameter

Former Member
0 Kudos

Hi,

Do not forget to add the RUN_SYS as a self defined application property in de properties of your Web Dynpro application using the application editor in NWDS.

You can also set a default value there.

Rgds,

Alain

Former Member
0 Kudos

I have created as you said with "RUN_SYS" but still iam getting null value

Sreejith1
Contributor
0 Kudos

Hi, What he says is correct and its works fine for me. please verify the property id.May be some minor mistake from your side.Try to copy the name of property ID in iview after expanding that property( by clicking).

Edited by: Mr.Ram on Dec 20, 2011 3:51 AM

Former Member
0 Kudos

try to use System.getProperty("SAPSYSTEMNAME")