Unit 1part1
Unit 1part1
PROGRAMMING
PREPARED BY
P.BRINDA,ASSISTANT
PROFESSOR-CSE
Internet Programming
Internet Programming
2
UNIT I WEBSITE BASICS, HTML 5, CSS 3, WEB 2.0
Web Essentials: Clients, Servers and Communication – The
Internet – Basic Internet protocols – World wide web – HTTP
Request Message – HTTP Response Message – Web Clients – Web
Servers – HTML5 – Tables – Lists – Image – HTML5 control
elements – Semantic elements – Drag and Drop – Audio – Video
controls – CSS3 – Inline, embedded and external style sheets –
Rule cascading – Inheritance – Backgrounds – Border Images –
Colors – Shadows – Text – Transformations – Transitions –
Animations.
Text book
H.M. Deitel, P.J. Deitel and T.R. Nieto, Internet and
World Wide Web: How to Program, Prentice Hall,
2011, 5th edition
4
References
6
Internet
Skills that are often required: Skills that are often required:
• CGI • XHTML
• PHP • Javascript
• ASP • Java
• Perl • Dreamweaver
• Java Servlet, … • Flash
• SMIL, XML …
7
Web Essentials
Request “document A”
document A
Client Server
8
Internet v.s. Web
9
Internet
16
Internet Protocols: IP
• IP is the fundamental protocol defining the
Internet (as the name implies!)
• IP address:
– 32-bit number (in IPv4)
– Associated with at most one device at a time
(although device may have more than one)
– Written as four dot-separated bytes, e.g.
192.0.34.166
Internet Protocols: IP
Source
Network 1
Network 3 Destination
Gateway Network 2
Gateway
Source
LAN 1
Gateway
Destination
OK.
{
Here’s a packet.
2. Send packet
with Source Destination
Got it.
acknowledgment.
Here’s a packet.
{
3. Resend packet
if no (or delayed) Here’s a resent packet.
acknowledgment.
Got it.
Internet Protocols: TCP
TCP, UDP
IP (IPv4, IPv6)
26
Domain Name Service (DNS)
• Run using UDP rather than TCP
• DNS is the “phone book” for the Internet
– Map between host names and IP addresses
– DNS often uses UDP for communication
Reverse Lookup
Analogy to Telephone
Network
• IP ~ the telephone network
• TCP ~ calling someone who answers,
having a conversation, and hanging up
• UDP ~ calling someone and leaving a
message
• DNS ~ directory assistance
Higher-level Protocols
• Many protocols build on TCP
– Telephone analogy: TCP specifies how we initiate
and terminate the phone call, but some other
protocol specifies how we carry on the actual
conversation
• Some examples:
– SMTP (email)
– FTP (file transfer)
– HTTP (transfer of Web documents)
The World Wide Web (WWW)
34
Static Web: HTML/XHTML, CSS
36
Client-Side Programmability
37
Server-Side Programmability
39
Web and the HTTP
(HyperText Transfer
Protocol)
World Wide Web
• Originally, one of several systems for
organizing Internet-based information –
Competitors: WAIS, Gopher, ARCHIE
• Distinctive feature of Web: support for
hypertext (text containing links)
– Communication via Hypertext Transport
Protocol (HTTP)
– Document representation using Hypertext
Markup Language (HTML)
World Wide Web
42
Web Client: Browser
43
Web Servers
Main functionalities:
– Server waits for connect requests
– When a connection request is received, the server creates a
new process to handle this connection
– The new process establishes the TCP connection and waits
for HTTP requests
– The new process invokes software that maps the
requested
URL to a resource on the server
– If the resource is a file, creates an HTTP response that
contains the file in the body of the response message
– If the resource is a program, runs the program, and
returns
the output
44
Web and H TTP
web page consists of objects, each object can be:
– HTML file,
– JPEG image,
– Java applet,
– audio file,
– …
web page consists of base HTML-file which includes several
referenced objects
– each object is addressable by a URL, e.g.,
http://www.school.edu/someDept/pic.gif
persistent HTTP
– Multiple objects can be sent over single TCP connection
between client and server
– Single TCP connection is needed to serve multiple resources.
– Server leaves the connection open even after serving the request
and closes connection on timeout.
HTTP:
Non-persistent HTTP(contains text, and a
suppose user enters URL: references to style.css )
www.SS.edu.jo/ANU/Web/SE432/se432.html
Start line
– Example: GET HTTP/1.1
/ANU/Web/SE432/SE432.html
Three space-separated parts:
– HTTP request method
– Request-URI
• Request-URI(Uniform Resource
is the portion of Identifier)
the requested URI that follows
the host name (which is supplied by the required Host
header field)
• In addition to http, some other URL schemes are https,
ftp, mailto, and file
– HTTP version
• We will cover 1.1, in which version part of start line must
be
exactly as shown
HTTP Request: Common Request
Methods
GET
– Used if link is clicked or address typed in browser
– No message-body in request with GET method
POST
– Used when submit button is clicked on a form
– Form information contained in the message-body
of request
HEAD
– Requests that only header fields (no body) be
returned in the response
What about HTTP 2
Method ?
types
HTTP/1.0:
GET
POST
HEAD
– asks server to leave requested object out of
response
HTTP/1.1:
GET, POST, HEAD
PUT
– uploads file in entity body to path specified in URL field
DELETE
– deletes file specified in the URL field
HTTP:
2-61
HTTP Request: Header field(s)
Header field structure:
– Field-name : Field-value
Syntax
– Field name is not case sensitive
– Field value may continue on multiple lines by starting
continuation lines with white space
– Field values may contain MIME types, quality
values,
and wildcard characters(*’s)
Multipurpose Internet Mail Extensions (MIME)
– Standardized way to indicate the nature and format
of a document (IETF RFC 6838)
HTTP Request: Common header
fields
64
Example: H T T P response message
status line
(protocol
status code HTTP/1.1 200 OK\r\n
status phrase) Date: Sun, 26 Sep 2010 20:09:20 GMT\r\
n Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007
17:00:02 GMT\r\n
header ETag: "17dc6-a5c-bf716880"\r\n
Accept-Ranges: bytes\r\n
lines Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html;
charset=ISO-8859-1\r\n
\r\n
data data data data data ...
data, e.g.,
requested
HTML file
The GetResponses program, I
Here’s just the skeleton of the program that provided the output
on the last slide:
– import java.net.*;
import java.io.*;
72
<!-- main.html -->
<!-- Our first Web page comment
--
>
<html>
<head>
<title>Internet and WWW How to Program
- Welcome define the title of the web page
</title>
</head>
<body>
<p>Welcome to XHTML!</p>
</body>
<p> - new paragraph
</html>
Example
73
An HTML document can be divided into 2
sections
head section
– contains information of how the page is formatted
– e.g. <title> … </title> can be found in head section to
indicate the title of the Web page when it is shown in
browser
body section
– contains the actual page contents
– e.g. <p>Welcome to HTML!</p> shows a line of text
“Welcome to HTML!” on the new paragraph
74
Tags
Tags: case insensitive
– For HTML, it is case insensitive
Browse will not display information within tag that does
not understand
Tags: no precise positioning
Many start tags define attributes that provide additional
information
E.g. <html>
start tag
75
Common Tags – Headers
Some text may be more important the others
HTML provides six headers, called header elements,
for specifying the relative importance of information
– <h1> … </h1>, <h2> … </h2> to <h6> … </h6>
It is assumed the text in <h1> is more important
than that in <h2> and so on so forth
By default, the size of the text that is more important
is bigger
76
<html>
<head>
<title>Internet </title>
</head>
<body>
6 headers are all used
<h1>Level 1 Header</h1> to indicate the relative
<h2>Level 2 header</h2>
<h3>Level 3 header</h3> importance of text
<h4>Level 4 header</h4>
<h5>Level 5 header</h5>
<h6>Level 6 header</h6>
</body>
</html>
77
Text under <h1> has the largest size
78