views:

1232

answers:

1

I'm pre-packaging a JSP web-app that relies on some file path settings found within web.xml. These settings are unknown at packaging time, because they reference a path the customer will set when deploying the entire application (of which the web-app is a management interface).

It seems that the easiest way to avoid tokens and file modifications in my installer script, is to ask the user for an install location, set this location as an environment variable (e.g JAVA_HOME), and have web.xml always reference that variable.

Is there a way to reference an environment variable value from within web.xml? Google searches lead to the J2EE method of SETTING environment variables from ejb xml files. This is not what I'm looking for.

Thanks Udi

A: 

i think you don't want to use environment variables (which i think are not accessible from web.xml), but environment entries [1, 2]. like so:

<env-entry>
    <env-entry-name>Bla/SomeFilePath</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/opt/bla</env-entry-value>
</env-entry>

you can use SomeFilePath like:

InitialContext ic = new InitialContext();
String s = (String) ic.lookup("java:comp/env/ejb/Bla/SomeFilePath");
ax
Problem is, the web app is generated code, which I would rather not mess with, except changing the value of a particular variable within web.xml. So I'm looking for a way to set just the value in a way that would reference a pre-set environment variable.
Udi Bar-On
as i said: i think it's not possible to use environment variables in deployment descriptors. no way around changing some code, i'm afraid.
ax