* Joakim Ahl�n <[EMAIL PROTECTED]> wrote:
>> Hello!
>>
>> In my servlet i need access to some environment variables
>> defined by an apache module for the request. How can i access them?
>>
>> I am using tomcat 3.3 and mod_jk. After looking at the mod_jk
>> source, i found the JkEnvVar directive. It seems that this
>> directive tells mod_jk to send the specified environment
>> variable to tomcat. But i can't find a way to access it on Java side.
>
> Im using the JkEnvVar in a setup right now, as follows, in apaches conf:
>
> JkEnvVar REDIRECT_URL REDIRECT_URL
>
> ...which passes the envvar REDIRECT_URL, calling it REDIRECT_URL on the
> java side. I later on fetch in java with:
>
> request.getAttribute("REDIRECT_URL")
>
> Works fine.
Thanks a lot.
> When first wanting to use this directive, i spent like an entire day
> trying to find even the slightest info about it. Everything that
> came up was some sourcecode patches for mod_jk containing the
> string... Does anybody know where this (and others?) directive is
> documented? I mean, there must be atleast something that states the
> usage of the directive with its arguments...
>From apache/mod_jk.c:
,----
| {"JkOptions", jk_set_options, NULL, RSRC_CONF, RAW_ARGS,
| "Set one of more options to configure the mod_jk module"},
| {"JkEnvVar", jk_add_env_var, NULL, RSRC_CONF, TAKE2,
| "Adds a name of environment variable that should be sent to Tomcat"},
| {NULL}
`----
But i am more interested in how you find out that the variable is
stored as a request attribute. The servlet API doc says:
,----
| getAttribute
| Returns the value of the named attribute as an Object,
| or null if no attribute of the given name exists.
|
| Attributes can be set two ways. The servlet container may set
| attributes to make available custom information about a request. For
| example, for requests made using HTTPS, the attribute
| javax.servlet.request.X509Certificate can be used to retrieve
| information on the certificate of the client. Attributes can also be
| set programatically using setAttribute(java.lang.String,
| java.lang.Object). This allows information to be embedded into a
| request before a RequestDispatcher call.
|
|
| Attribute names should follow the same conventions as package names.
| This specification reserves names matching java.*, javax.*, and
| sun.*.
`----
--Nikolaus
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>