I've made a lot of search about my issue, but let's face it, I've found no workaround.
I'm deploying a war file on a Tomcat7 application server. Everything is ok. But when I target my application, with the help of the developer console, I can see that all my links (relative and absolute) are broken.
So, all my assets, internal API call, and finally my application are not accessible.
Example :
My app is deployed to : http://localhost:8585/myapp/
.
My links (absolute and relative) are base on this url : http://localhost:8585/
, then it's logical that all my links are broken because they're not targeting the right url.
I would like to keep my application agnostic of any deployment dependency, constraint or constant. And it would be fantastic if you can help me with some proper way to solve my issue : reading that all I need to do is to rename my war ROOT.war to be deployed at root level make me sick.
Have a great day and thank you, Max.
Well, you have basically 3 options to achieve what you (as far as I understand) want:
the one you won't read: deploy the app in ROOT context; but, as you have correctly stated, makes the app deployment dependent, and, of course, is not always possible;
you could put a proxy (e.g. Apache HTTPD) in front of your Tomcat and set some rewrite rules to translate http://localhost/
to http://localhost:8585/myapp/
- this is sometimes useful, but in most cases too complicated, and sometimes not possible (e.g. due to a deployment policy in the company);
IMHO the most proper one: use of relative links (as stated by Henry in his comment) and use of the ContextPath (request.contextPath
in JSP);