Question
In a web server, ten WebPages are stored with the URLs of the form http://www.yourname.com/var.html; where, var is a different number from 1 to 10 for each Webpage. Suppose, the client stores the Webpage with var = 1 (say W1) in local machine, edits and then tests. Rest of the WebPages remains on the web server. W1 contains several relative URLs of the form "var.html" referring to the other WebPages. Which one of the following statements needs to be added in W1, so that all the relative URLs in W1 refer to the appropriate WebPages on the web server?
Official answer and solution
- Official answer
- B
- From
- Official GATE 2015 answer key
Solution
Identify the standard HTML tag used to specify the base URL for resolving relative links.
When a web page W1 is stored and opened locally on a client machine, its current document base URL is the local file system path (e.g., file:///C:/...).
Any relative URL inside W1 of the form var.html would, by default, resolve relative to that local directory.
The HTML base element specifies the base URL to be used for all relative URLs contained within a document. By adding:
<base href="http://www.yourname.com/">
in the head section of W1, any relative link "2.html" automatically resolves to http://www.yourname.com/2.html on the remote web server.
This corresponds to Option B.
B
Confusing the document-level base tag with individual anchor tags, which only apply to a single link rather than all relative URLs across the document.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2015 Computer Science and Information Technology (CS) Session 3
- Question
- 18 of 65, printed as CS Q.8
- Section
- Computer Science and Information Technology
This question is from a part of the syllabus that is no longer in GATE CS. It is kept because it was in the paper.
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.