Author: markt
Date: Fri Mar 28 14:18:25 2008
New Revision: 642391
URL: http://svn.apache.org/viewvc?rev=642391&view=rev
Log:
Remove hack for getting env since JDK >= 1.5 provide a suitable method. Fixes
issue with CGI, env and vista.
Modified:
tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
Modified: tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=642391&r1=642390&r2=642391&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java (original)
+++ tomcat/trunk/java/org/apache/catalina/servlets/CGIServlet.java Fri Mar 28
14:18:25 2008
@@ -304,13 +304,7 @@
Boolean.valueOf(getServletConfig().getInitParameter("passShellEnvironment")).booleanValue();
if (passShellEnvironment) {
- try {
- shellEnv.putAll(getShellEnvironment());
- } catch (IOException ioe) {
- ServletException e = new ServletException(
- "Unable to read shell environment variables", ioe);
- throw e;
- }
+ shellEnv.putAll(System.getenv());
}
if (getServletConfig().getInitParameter("executable") != null) {
@@ -636,55 +630,6 @@
public static void main(String[] args) {
System.out.println("$Header$");
}
-
- /**
- * Get all shell environment variables. Have to do it this rather ugly way
- * as the API to obtain is not available in 1.4 and earlier APIs.
- *
- * See <a href="http://www.rgagnon.com/javadetails/java-0150.html">Read
environment
- * variables from an application</a> for original source and article.
- */
- private Hashtable<String,String> getShellEnvironment() throws IOException {
- Hashtable<String,String> envVars = new Hashtable<String,String>();
- Process p = null;
- Runtime r = Runtime.getRuntime();
- String OS = System.getProperty("os.name").toLowerCase();
- boolean ignoreCase;
-
- if (OS.indexOf("windows 9") > -1) {
- p = r.exec( "command.com /c set" );
- ignoreCase = true;
- } else if ( (OS.indexOf("nt") > -1)
- || (OS.indexOf("windows 20") > -1)
- || (OS.indexOf("windows xp") > -1) ) {
- // thanks to JuanFran for the xp fix!
- p = r.exec( "cmd.exe /c set" );
- ignoreCase = true;
- } else {
- // our last hope, we assume Unix (thanks to H. Ware for the fix)
- p = r.exec( "env" );
- ignoreCase = false;
- }
-
- 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 );
- if (ignoreCase) {
- key = key.toUpperCase();
- }
- envVars.put(key, value);
- }
- return envVars;
- }
-
-
-
-
-
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]