To get the hostname you can create a Java action that returns a string and add this code:
return InetAddress.getLocalHost().getHostName();
Don't forget to import java.net.InetAddress:
import java.net.InetAddress;
The Community Commons module in the Marketplace has the GetApplicationURL action that returns the runtime URL of the application. Would that be what you need?
https://marketplace.mendix.com/link/component/170
I hope this helps.