tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Pringle <Jason.Prin...@amdocs.com>
Subject Getting an absolute path into a servlet's context-param value w/o hardcoding in web.xml
Date Fri, 29 Jul 2011 23:04:41 GMT
Hi all,

We have a 3rd party application that is deployed into our environment.  As it is 3rd party
we have no control over changing the servlet code itself.

As part of the "configuration" of the servlet to be deployed into an environment, it wants
a directory path passed as a servlet context parameter:

(WEB-INF/web.xml)
....
  <context-param>
    <param-name>3rd-party-app.home</param-name>
    <param-value>/path/to/directory</param-value>
  </context-param>
....

In our environments, "/path/to/directory" will be different for different deployments, and
so we don't want to hardcode this into the web.xml else the WAR is non-portable.

A very annoying work around we came up with is to specify a relative path, but this has the
nasty effect of forcing the container to be started from a specific directory (ops guys don't
like that!):

(WEB-INF/web.xml)
  <context-param>
    <param-name>3rd-party-app.home</param-name>
    <param-value>../../relative/path/to/directory</param-value>
  </context-param>

I'm sure there's a better way to do this, but am still scratching my head.

Does tomcat still dereference the system properties when parsing a WAR's web.xml?  Would something
like this work?

(catalina.properties)
foo.home=/path/to/directory

(WEB-INF/web.xml)
  <context-param>
    <param-name>3rd-party-app.home</param-name>
    <param-value>${foo.home}</param-value>
  </context-param>


I've also thought about a custom listener or similar that would load before the context-params
are read and set the context-param value by reading a system property set via catalina.properties.

Thanks!

--Jason Pringle

This message and the information contained herein is proprietary and confidential and subject
to the Amdocs policy statement,
you may review at http://www.amdocs.com/email_disclaimer.asp


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message