Fetching environment variables from servlets
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Ravishankar_CS
Posted On:   Thursday, November 14, 2002 04:28 AM

I want to access environment variables from servlets. I tried putting the following piece of code in the init function of my servlet but it is unable to pick up the value of the environment variable and it is returning null even if that variable is set to some value. Properties envVars = new Properties(); Runtime r = Runtime.getRuntime(); BufferedReader br = new BufferedReader ( new InputStreamReader( p.getInputStream() ) ); String line; while( (line = br.readLine()) != null ) { int idx = line.indexOf( '=' ); String key = line.substring( 0, idx ); String value = line.substring( idx+1 ); envVars.setProperty( key, value ); } System   More>>

I want to access environment variables from servlets.
I tried putting the following piece of code in the init function of my servlet but it is unable to pick up the value of the
environment variable and it is returning null even if that
variable is set to some value.

			
Properties envVars = new Properties();
Runtime r = Runtime.getRuntime();
BufferedReader br = new BufferedReader
( new InputStreamReader( p.getInputStream() ) );
String line;
while( (line = br.readLine()) != null ) {
int idx = line.indexOf( '=' );
String key = line.substring( 0, idx );
String value = line.substring( idx+1 );
envVars.setProperty( key, value );
}
System.out.println(envVars.getProperty("ARCHIVE5_ROOT"));

// ARCHIVE5_ROOT is the variable i want to retrieve.it is
//set to "c: "

Can anyone tell me as to how to do it?    <<Less

Re: Fetching environment variables from servlets

Posted By:   Christopher_Koenigsberg  
Posted On:   Thursday, November 14, 2002 07:19 AM

About | Sitemap | Contact