Absolute URL Generation

Sometimes it is important to create fully-specified URLs. For some of these cases you could use the host header and determine the port from the list of active ports configured on the server. This procedure often works well, but not always. First of all, the cases that need fully-specified URLs are considered:

·        When a test URL is generated to start the application in the browser.

·        When the protocol is switched. This is usually a switch from HTTP to HTTPS to ensure the data transfer is secure. This case arises often.

·        When a Java applet is loaded sometimes a fully-specified URL is required in a complex frameset, because otherwise the applet is loaded from the server where the root document is located rather than from the frame owner where the applet is located.

·        Return URLs in typical catalog applications. Here a URL is required that is used to return data to the server and for the specific application. In this case a fully-specified URL is also necessary.

The first example listed is a special case, as there are no incoming HTTP requests from which you could use the host header.  So a completely new URL has to be generated, without any prior information of possible server names. In all the other examples an incoming HTTP request is available, from which the host header can be used for heuristic information for filtering relevant entries.