Is there any way to get the value of following Apache Web Server Environment Variables?

Alessandro A. Garbagnati


I'm afraid that te short answer is no, there isn't.

Normally those environment variables are available only through the Common Gateway Interface. Many Apache modules (like mod_perl) get those variables and allow the process that they generate to access them or directly, or through basic OS calls.

It looks like that mod_jk is not passing all those variables and, through java, there are no way to access to system environment variables (the System.getEnv() has been deprecated). It's possible that mod_jserv was originally designed to pass those variables (on ApacheJServ's jserv.properties configuration file there is a property wrapper.env.copyall=[true|false]). But it seems that the Ajp12Connector isn't reding those variables.

I don't really know how to get those variables, anyway. The Tomcat process is totally indipendent from the Apache process, so even if you use some 'manual' method (executing an external process) I don't think you will be able to get them.

Maybe patching mod_jk (or mod_jserv) and the related Connector... or eventually, reading the stream generated by executing a URLConnection to a CGI that list them...

Sorry & Ciao!

[FYI, you can get some environment variables via the Servlet API. See http://www.jguru.com/jguru/faq/view.jsp?EID=11699 and http://www.jguru.com/faq/view.jsp?EID=296467. - Alex]