Environment variable referance in Web.xml

Discussions

Web tier: servlets, JSP, Web frameworks: Environment variable referance in Web.xml

  1. Environment variable referance in Web.xml (1 messages)

    Hi All, I have an application. Currently I am initializing my external properties through the below entries in web.xml. ActionServlet ActionServlet com.jkcool.wbt.bean.common.WebBssServlet application /config/ApplicationResources conf /config/ApplicationConf.properties ] ActionServlet ActionServlet com.jkcool.wbt.bean.common.WebBssServlet application /config/ApplicationResources conf /config/ApplicationConf.properties Right now , I have only one set of property files. But when I go for deployment , I need 3 set of property files - dev,qa and modl for deployment in different regions. Is it possible to have entries in web.xml like the one below ActionServlet ActionServlet com.jkcool.wbt.bean.common.WebBssServlet application /config/$region_var/ApplicationResources conf /config/$region_var/ApplicationConf.properties Where $region_var will be an environment variable in Websphere application server. Is it possible ? Or is there any other way to put external variables in web.xml ? Thank you
  2. I am not sure whether it is a possible solution for you or not. Let me give it a try. First, env variable(s) have to be passed with -D from command line while running app server: java -DconfPath=/usr/path/to/conf .... Second, You may want to use custom code in your servlet's (WebBssServlet) init method to interpret your env variable something like this ... String paramValue = config.getInitParameter("conf"); if(paramValue.indexOf("$")) { // extract name of variable 'varName' based your pattern envVarValue = System.getProperty(varName); // replace interpreted environment variable value in paramValue ... } Anil.