URL
Hypertext
- text with links to other text
- click on links takes you to somewhere else
- web adapted the idea, links specification
- URL(uniform resources locators)----provide names for web content
Parts of URL
- scheme (http:) identifies protocol used to fetch content
- host name(//host.company.com): name of a machine to connect to
- server’s port number(80): allows mutiple servers to run on the same machine
- hierachical portion(/a/b/c.html): used by server to find content
- query parameters(?user=Alice&year=2008): provides additional parameters
- fragement(#p2): have browser scroll page to fragmet (html: p2 is anchor tag)
- used on the browser only; not send to the server
URL Schemes(eg:http)
- http: the most common scheme; use HTTP protocol
- https: similar to http; except that it uses SSL encyption
- file: read a file from a local disk
- websocket: create a TCP connection
- mailto: open an email program composing a message
- there are many other schemes (~350)
- example: mongodb: points to a MongoDB database
URL: hierarchical portion(a/b/c.html)
- passed to the web server for interpretation. early web servers:
- path name for a static HTML file
- path name of a program that will generate the HTML content(eg: foo.php)
- web server programmed with routing information
- map hierachical positon to funcion to be performed and possibly the function’s parameters.
- applicaiton programming interface(API) design, example:
- /user / create
- / user / list
- /user / 0x23490
- /user / 0x23433
- /user / delete /0x23433
Query Parameters(eg: ?user=Alice&year=2008)
- traditionally has been to provide parameters to operation
- such as: http://www.company.com/showOrder.php?order=4621407
- for morden apps has implications of when the browser switches pages
Links
- browser maintains a notion of current location(i.e. URL)
- links: content in a page which when clicked on, causes the browser to go to a URL
- links are implemented with the tag:
- such as
<a href="http://www.company.com/news/2009.html">2009 News</a>
- such as
Different types of links
- Full URL:
- such as
<a href="http://www.company.com/news/2009.html">2009 News</a>
- such as
- Absolute URL:
- such as
<a href="/stock/quote.html">
- same as
http://www.xyz.com/stock/quote.html
- such as
- Relative URL ( intra-site-links ):
- such as
<a href="2008/March.html">
- same as
http://www.xyz.com/news/2008/March.html
- such as
- Define an anchor point(a position tha can be referenced with #notion):
- such as
<a name="sec3">
- such as
- Go to a different place in the same page:
-such as<a href="#sec3">
Uses of URLs
- loading a page: type URL into your browser
- loading a image:
<img src="..." />
- loading a stylesheet:
<link rel = "stylesheet" type = "text/css" href = "...">
- embedded a page:
<iframe src= "http://www.google.com">
URL Encoding
- what if you want to include a punctuation character in a query value?
- such as
http://www.stats.com/companyInfo?name=C&H Sugar
- such as
- any character in a URL other than A-Z, a-z, 0-9, or any of -__~. must be represented as %xx, where xx is the hexadecimal value of the character
- such as
http://www.stats.com/companyInfo?name=C%26H%20Sugar
- such as
- escaping is a commonly used technique and also a source of errors
Miscellaneous Topics
- computer scientists take on hypertext:
- need to have referential integrity
- the web (done by physicists):
- Error 404
- URI(uniform resources identifier) vs. URL(uniform resources locator)