My website calls a rest service which is also on the same application. I don't want to change the domain of the rest address if it's hosted on a different domain name and/or port. I want to get the domain, port and application path programmatically.
If we are accessing the website like
then I should get http://example.com
or if our address is like below
http://example.com:8080/ArticleSite/article1
then I want to get http://example.com:8080/ArticleSite
How can this be done?
I did look at the answers at
What's the best way to get the current URL in Spring MVC?
but non are getting the application path.