The Domino Directory (names.nsf) has a server document for every server.
If you're looking at a server document in the Notes client, you should see a "fully qualified internet host name" under the Basics tab, and "host names(s)" under the Internet Protocols->HTTP tab.
You can get the value of one of those fields by a lookup on the server name in server-side javascript.
However, those host names might not be what you want. You might prefer to use another domain for the same server that doesn't match the host names in the server document.
In that case, you could make a configuration document with a custom form in your xpage database, mapping server names to the preferred domain names.
Then you'd be performing a lookup on the server name in your own database, which should be slightly faster than looking up the Domino Directory.
Once you have a domain name, you can just use database.getFilePath() to make the rest of the URL, but if your Notes client runs on Windows you'll need to replace backslashes with forward slashes.