To get the hostname you can create a Java action that returns a string and add this code:
Don't forget to 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?
I hope this helps.