views:

181

answers:

1

My web application uses the same database configuration as the application XYZ. I have a resource declaration for a context in server.xml, so I have a duplicated configuration (once for web application and once for application XYZ). How can I read some 'external' values into server.xml? For example:

<Resource name="jdbc/MyDB" username="${user}" password="${pwd}" url="${url}" ...
+1  A: 

In short - you can't do this with tomcat configuration. Also, specific for server.xml, the only way to reload it is to restart the server.

If you need the datasource only within one web application, then a way to do it is by using the spring framework and PropertyPlaceholderConfigurer.

Another way might be to inherit from tomcat's StandardHost and StandardContext and do some custom parsing.

David Rabinowitz