You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Kim Goldov <kg...@gmail.com> on 2011/06/02 00:31:54 UTC

Re: set environment variables in tomcat

Thanks everyone. Here is what I ended up with.

In my PerlHeaderParserHandler:

    $r->subprocess_env(AA_MYVAR => 'myvalue');
    $r->subprocess_env();

In jk.conf:

    JkEnvVar      AA_MYVAR

In Tomcat:

      out.println("AA_MYVAR is: " + request.getAttribute("AA_MYVAR") );

-- 
Kim

Re: set environment variables in tomcat

Posted by André Warnier <aw...@ice-sa.com>.
Kim Goldov wrote:
> Thanks everyone. Here is what I ended up with.
> 
> In my PerlHeaderParserHandler:
> 
>     $r->subprocess_env(AA_MYVAR => 'myvalue');
>     $r->subprocess_env();
> 
> In jk.conf:
> 
>     JkEnvVar      AA_MYVAR
> 
> In Tomcat:
> 
>       out.println("AA_MYVAR is: " + request.getAttribute("AA_MYVAR") );
> 

Right.
But don't forget that this is very Apache/mod_jk/Tomcat specific.
A more generic way of doing this would be to set an additional header in the request at 
the Apache level, and get this header at the Tomcat level with request.getHeader().
That would work with any proxying scheme between Apache and a back-end servlet engine 
(mod_jk, but also mod_proxy_http and mod_proxy_ajp).