INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid...
Transcript of INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid...
![Page 1: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/1.jpg)
1
INLS 760 – Web Databases
Lecture 1 – Intro, HTTP, HTML,
CSS, CGI
Dr. Robert Capra
Spring 2013
![Page 2: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/2.jpg)
2
What are web databases?
![Page 3: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/3.jpg)
3
What are web databases?
Amazon?
UNC Library website?
craigslist?
Inls760 web site?
engadget?
SILS website?
Ibiblio?
Census bureau site?
Slashdot? Web banking?
Jcpenney.com?
ACM DL? nytimes.com?
Google?
Wikipedia?
Any website you can think of?
![Page 4: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/4.jpg)
4
Course Information • Instructor: Dr. Robert Capra
• Office: Manning 210
• Email: r<lastname> at unc dot edu
• Prerequisites: INLS 572 or equivalent, INLS 623 and
programming experience
• Optional textbooks:
– PHP and MySQL Web Development, by Luke Welling and Laura
Thomson
![Page 5: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/5.jpg)
5
Course Objectives • Solidify understanding of web protocols and standards: HTTP,
HTML, CSS, CGI.
• Gain practical experience implementing Web databases using: 1) “LAMP” (Linux, Apache, MySQL, and PHP) environment, and 2) ASP.
• Learn techniques for dealing with security, user authentication, web transactions, session management, and keyword search.
• Work with Javascript and DOM client-side technologies in a web database context.
• Introduce Ruby on Rails and understand how it supports rapid development.
• Learn about emerging Web database technologies and trends.
• Develop the ability to critically assess and review program code for Web databases.
![Page 6: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/6.jpg)
6
Hardware and Software
• Main development environment: – “LAMP” (Linux, Apache, MySQL, and PHP)
• Although you will have access to these through your SILS computer accounts, you are encouraged to install and configure a LAMP environment on your own computer.
• Do NOT un-install your current operating system – you can run LAMP in a "virtual machine" so that it will not interfere with your existing operating system.
![Page 7: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/7.jpg)
7
HTTP Protocol
• Hypertext Transfer Protocol
• Client-server request / response
– TCP/IP, default port 80
• Connectionless and stateless
– After request/response, connection is dropped
– No state kept between requests
• Exceptions for “keep-alive” and HTTP 1.1 persistent connections
• Extensible data types
– MIME types (i.e. text/plain, text/html)
Notes from: <http://www.serverwatch.com/tutorials/article.php/10825_1354871_2>
![Page 8: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/8.jpg)
8
Universal Resource Identifiers
(URIs)
• http://www.w3.org/Addressing/URL/uri-spec.html
• Location – URL
• Name – URN
• Protocol :// Server / Path / Object
• Protocols include
– http, ftp, mailto, news, file
![Page 9: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/9.jpg)
9
HTTP transaction [rcapra@ruby]$ telnet www.ils.unc.edu 80
Trying 152.2.81.1...
Connected to ruby.ils.unc.edu (152.2.81.1).
Escape character is '^]'.
GET /courses/2008_spring/inls760_001/lect1/foo.html HTTP/1.1
Accept: text/plain, text/html
Host: www.ils.unc.edu
HTTP/1.1 200 OK
Date: Tue, 15 Jan 2008 18:47:49 GMT
Server: Apache/2.0.52 (Red Hat)
Last-Modified: Tue, 15 Jan 2008 18:46:48 GMT
Content-Length: 118
Content-Type: text/html; charset=ISO-8859-1
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
Here is some text.
</body>
</html>
Request
headers
Response
headers
Entity-
body
![Page 10: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/10.jpg)
10
HTTP Requests
• GET
– Commonly used to retrieve a document
• HEAD
– Returns all headers, but no entity-body
• POST
– Commonly used to upload data to the server
• e.g. forms
![Page 11: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/11.jpg)
11
HTML
• Authoritative resource: W3C specifications
– HTML 4.01
• http://www.w3.org/TR/html4/
– XHTML 1.0
• http://www.w3.org/TR/xhtml1/
![Page 12: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/12.jpg)
12
HTML – Inline Styles <html>
<head>
<title>Test</title>
</head>
<body bgcolor=silver>
<table border="1" style="text-align: left; width: 100%;">
<tbody>
<tr>
<td style="text-align: center; background-color: blue;">
Working with HTML<br>
</td>
</tr>
<tr>
<td style="background-color: green;">
<h3 align=center>is fun!!!</h3>
</td>
</tr>
</tbody>
</table>
</body>
</html>
lect1/inlinestyle.html
![Page 13: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/13.jpg)
13
![Page 14: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/14.jpg)
14
Cascading Style Sheets (CSS) <html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href= "example.css" />
</head>
<body>
<table>
<tbody>
<tr>
<td class="firstrow">
Working with HTML<br>
</td>
</tr>
<tr>
<td class="secondrow">
<h3>is fun!!!</h3>
</td>
</tr>
</tbody>
</table>
</body>
</html>
lect1/css.html
![Page 15: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/15.jpg)
15
Cascading Style Sheets (CSS) body {
background: silver;
}
table {
border: 2px solid black;
text-align: left;
width: 100%;
}
td.firstrow {
text-align: center;
background: blue;
}
td.secondrow {
background: green;
}
h3 {
text-align: center;
}
CSS resources:
http://www.w3.org/Style/CSS/
http://www.w3schools.com/css/css_intro.asp
lect1/example.css
![Page 16: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/16.jpg)
16
Forms & CGI <html>
<body>
<h1>Test Form</h1>
<form method="post” action="http://www.ils.unc.edu/courses/ 2008_spring/inls760_001/lect1/form1.php">
First name: <input name="firstname" maxlength="20" size="20">
<br>
Last name: <input name="lastname" maxlength="20" size="20">
<br>
Password: <input name="password" type="password"
maxlength="20" size="20">
<br>
<input type="submit" value="Submit">
<input type="reset" value="Clear form">
</form>
</body>
</html>
lect1/form1.html
![Page 17: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/17.jpg)
17
![Page 18: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/18.jpg)
18
CGI POST
POST /courses/2010_spring/inls760_001/lect1/form1.php HTTP/1.0
Accept: */*
Content-type: application/x-www-form-urlencoded
Content-length: 49
firstname=robert&lastname=capra&password=12345678
This entity-body is then sent to the form1.php script.
Request
headers
Entity
body
Note: For telnet example, type in by hand
![Page 19: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/19.jpg)
19
CGI Response
HTTP/1.1 200 OK
Date: Tue, 12 Jan 2010 22:22:13 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Content-Length: 61
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Firstname = robert<br>Lastname = capra<br>Password = 12345678
![Page 20: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/20.jpg)
20
URL-encoded data
Another way to send data to the server is to
include it as part of a URL
(only good for small amounts of data)
firstname=robert&lastname=capra&password=12345678
Content-type: application/x-www-form-urlencoded
![Page 21: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/21.jpg)
21
Using GET <html>
<body>
<h1>Test Form</h1>
<form method=“get” action="http://www.ils.unc.edu/courses/ 2010_spring/inls760_001/lect1/form2.php">
First name: <input name="firstname" maxlength="20" size="20">
<br>
Last name: <input name="lastname" maxlength="20" size="20">
<br>
Password: <input name="password" type="password"
maxlength="20" size="20">
<br>
<input type="submit" value="Submit">
<input type="reset" value="Clear form">
</form>
</body>
</html>
lect1/form2.html
![Page 22: INLS 760 – Web Databases• Introduce Ruby on Rails and understand how it supports rapid development. • Learn about emerging Web database technologies and trends. • Develop the](https://reader034.fdocuments.in/reader034/viewer/2022052017/602fcfeea7c49a239d63c15d/html5/thumbnails/22.jpg)
22
CGI GET
GET /courses/2010_spring/inls760_001/lect1/form2.php?
firstname=robert&lastname=capra&password=12345678 HTTP/1.0
Referer: http://www.ils.unc.edu/courses/2010_spring/ inls760_001/lect1/form2.html
User-Agent: Mozilla/1.1N (X11; I; SunOS 5.3 sun4m)
Accept: */*
Accept: image/gif
Accept: image/x-xbitmap
Accept: image/jpeg