Let’s say that I have something like this in my web.xml file.
<filter name="foo">
<init-param>
<param-name>fooBarUrl</param-name>
<param-value>http://foo.bar.com</param-value>
</init-param>
</filter>
Say there are different url values (for the param-value above) for dev/test/production. Is there a way that you can use filters and/or profiles in the pom to eliminate the need for changing this every time the application moves to a different stage? I.E. for dev it would be http://localfoo.com, and for test it would be http://testserver.com, etc.
You can use Maven’s resource filtering ro replace properties with values at build time, e.g. by using different Maven profiles to set the properties values.
On the other hand you could use servlet parameters and move them to the context configuration, so your web.xml references them and they are actually configured in the application server where the .war file is deployed. That way, the application server administrator can reuse the same war file for each environment by just configuring it at server level.
In Tomcat for example, you can set the values in the context.xml file: