I am not sure if my heading makes sense. This code example will make things clear, perhaps. I am hosting a simple Web service using Tomcat. I also have some HTML/JavaScript making calls to the web service. I use the XMLHttp for the same. This is an example:
var xmlhttp=new XMLHttpRequest();
xmlhttp.open('GET','http://mywebservice.com/rest/main',false);
//xmlhttp.open('GET','http://localhost:8080/appName/rest/main',false);
xmlhttp.send();
getNames(xmlhttp);
Each time I deploy this web service on a certain Tomcat instance (local or cloud), the URL in the xmlhttp.open() call needs to be manually modified. See the commented code.
Is it possible to fetch this base URL programmatically ?