981121-4

A web document at URL http://foo.bar/alpha/beta/epsilon contains the following code:

<HEAD>
<BASE href="http://foo.bar/alpha/gamma">
</HEAD><BODY>
<A href="../delta/exit.html">
Which document will be retrieved through the link in the body above?

Answer

The document at "http://foo.bar/delta/exit.html".

  1. Start with the BASE at "http://foo.bar/alpha/gamma"
  2. Ignore "gamma" since only the directory is used
  3. The base directory is thus "http://foo.bar/alpha/"
  4. ".." moves one step up in the path to "http://foo.bar/"
  5. Append "/delta/exit.html" to get "http://foo.bar/delta/exit.html"

Incorrect answers

A common error was to give the reply "http://foo.bar/alpha/delta/exit.html". This would have been correct if the <HEAD> had contained the statement
<BASE href="http://foo.bar/alpha/gamma/">. But since there is no "/" after "gamma" this is a file name, not a directory, and is stripped before resolution.

Another common error is to use the URL of the web document and not the URL in the BASE element. But the BASE element takes over the URL of the web document.

List of exam questions