I have a couple of Java applications running in TomCat containers behind Apache Httpd. In Apache Httdp you can set Env variables with SetEnv FOO bar, if you have mod_env installed. How can I read those variables in my Java applications running inside TomCat?
The Java applications are mostly build with Stripes, if that helps.
I have a couple of Java applications running in TomCat containers behind Apache Httpd.
Share
Because Tomcat is started outside of Apache it does not have access to the Apache environment. This means you need some way of passing environment variables from Apache to Tomcat.
If you are connecting Apache and Tomcat using
mod_jk, you can use theJkEnvVardirective to pass specific variables to Tomcat. From the mod_jk documentation:If you are using the HTTP proxy (
mod_proxy) instead ofmod_jk, you can pass environment variables as request headers usingmod_headers, something like:…and then in Tomcat you would have to extract the
X-MYVARheader.