You could use relative URLs from the start.
You can always write a script to identify these strings and convert them
can't we do anything without tapering with the code.
a best practice when developing websites or webapps is you *never* hard code any absolute references/paths in your HTML, JSP, etc. Always use relative paths!
However, you could deploy the necessary hard-coded dirs/resources in separate locations (wars). For example, if you have /images/* as the location of your images, put your images into the root of a new webapp and deploy it as /images.
BUT, you should just take the time now and refactor all of your code and do it properly, using relative paths.