Title: sa st dadt
1??sa???? st? d?ad??t??
2??sa???? st?? e??t?ta
- ?ata???s? t?? ?e?t?????a? t?? web
- ???t??? Client/Server
- ???t?????a ep????????a? d??t???
- Te???a ?a? p???? a????t?? s?st?µ?t??
- S??s? a????t?? se s??s? µe ??e?st? s?st?µata
- S??t?µ? pa???es? t?? s?µa?t???te??? standards t??
d?ad??t??? - ??sa???? st? ßas??? a???te?t????? Web
3WEB
- WEB?a???sµ??, d?ad?ast???, d??aµ???,
?ata?eµ?µ??? s?st?µa - WEB ????e? p??? ap? t? Internet
- WEB p??t? ?e??? s?st?µ?t??, p?? e?s?µat?????
p????f???a?? s?st?µata ß?se?? p??
?atas?e??st??a? st? pa?e????
4WEB
- WEB e????? ???s?, HTML e????? s????af? se??d??
- ????, ?p?????? a??et?? d?s????e? st?? a??pt???
efa?µ???? - ??t?e? d?s????a?
- ?????p??, ded?µ??a, d?ad??as?e?, d??t?a
ep?????????? µe ?at?????? te???????a - ????? ep??e???µat???t?ta?, s?ed?as??, t?????,
????????????a?, ????????a?
5???sµ?? µ??t???? Client/Server
- Client/Server ?ata?eµ?µ??? e?d??? ?p?????st????
s?st?µ?t?? - ????de? ????sµ???? se d?af??et????? ?/?
s??e??????ta? ??a ??a s??p? - ?? ????sµ??? t?? client e?te?e?ta? se ??a
p??s?p??? ?p?????st? ?p?ß???e? a?t?se?? - ?? ????sµ??? t?? server, e?te?e?ta? se ??a ta??
?p?????st? e??p??ete? t?? a?t?se?? t?? client - client server ep??????????, ??a ??e?????ta? ??a
p??t??????
6S??s? client/server a
- server dapa?? t? µe?a??te?? µ???? t?? ?s???? ??a
e??p???t?s? t?? a?t?se?? t?? clients, p.?. - ??t?se?? ??a se??da web
- ??t?se?? ??a e???af?? ap? ß?s? ded?µ????
- ??t?se?? ??a µ???µata ??e?t??????? ta??d??µe???
- ???p???t?s? a?t?s??
- ???sßas? se p?????µµata / se ß?se??...
- ? server st???e? t? ap?t??esµa st?? client
- ? client epe?e????eta? t? ap?t??esµa
7S??s? client/server ß
- ?? µ??t??? client/server e??a? s?et??? ???
- ?a?a??te?? µ??t???
- ?ed?µ??a, epe?e??as?a, d?ep?f??e?a ???st? se
?e?t???? ?p?????st?, µe ?e???? p??sßas? - Mainframe computers,
- (t? µ??t??? e??a? a??µ? e? ???se? ...)
- ??e?s? t?? p??s?p???? ?p?????st??
- F????? ep????????a a????p?? µ??a???
- ??p??? epe?e??as?a ded?µ???
8Client/Server ????sµ??? a
- ??s? ap? t? ????sµ??? ?a e??a? st?? client ?a?
p?s? st?? server - ??a??ese t?? efa?µ??? se t??a tµ?µata
- ?ed?µ??a
- ?pe?e??as?a
- ??ep?f??e?a ???st?
- ???tas? ??ep?f??e?a ???st? st?? client,
ded?µ??a/ epe?e??as?a st?? server
9Client/Server ????sµ??? ß
- Se p????? a???te?t?????? client/server
- ??ep?f??e?a ???st? µ???? epe?e??as?a??client
- ??ep?f??e?a ???st? µe???? ded?µ??a?client
- ?e???? µ???? t?? efa?µ???? st?? client
- ??e??e?t?µata
- ?e??s? ?????f???a? st? d??t??
- ?e??s? f??t?? t?? server
- ?a??te?? a???p???s? t?? client
- ?e???e?t?µata
- ????p???? ????sµ???
- ????t?s? ap? ?s?????? p??s?p????? ?p?????st??
10Internet client/server
- ?? Internet ßas?st??e st? client/server µ??t???
- ?p???e a????? s??des?? d?af??et???? ?p?????st????
s?st?µ?t??, µe d?af??et??? ?e?t??????? s?st?µata - ?? ?nternet ßas?st??e se a????t? p??t?pa (open
standards)
11?????t? pe??ß?????ta (Open environments)
- ?a a????t? s?st?µata e??a? t? ??t??µe?? sta
p????f????? s?st?µata - ??????eta? ????sµ???/????? d?af??et????
p????e?s?? ?a? ep???????e? ????? p??ß??µata - ?????t? pe??ß??????s?ed?as? ??????/????sµ????
s?µf??a µe e????? d?aded?µ??e? p??d?a??af??
12?a?a?t???st??? a????t?? s?st?µ?t??
- F???t? ?d?a efa?µ??? se ?p?????st?? d?af??et????
a???ste?t??????/?e?t???????? s?st?µat?? - ???µa???µe?a ?d?a efa?µ??? se ?p?????st??
d?af??et???? ?s???? - ??a-?e?t???????t?ta ???e??? a?ta??a??
p????f???a? µeta?? ?p?????st???? s?st?µ?t?? - ????????s? s??ep?? d?e-ep?f??e?a ???st? se ??a
ta s?st?µata?e??e??? ???s? ?/?.
13?????t? s?st?µata ?a? Web a
- To Web ßas??eta? se a????t? p??t?pa
- ?? Web efa?µ???? µp????? ?a t?????? ap?
p??s?p????? ?p?????st?? µ???? ?????? ap?d?s??
(?a? t?µ??!) servers?µetaf??s?µe? - Web client/servers e??a? d?a?e?t????????, t??????
se UNIX/Windows/Linux . - Web browsers p??sf????? ????????s?, ?d?a
d?ep?f??e?a ???st? pa?t??
14?????t? s?st?µata ?a? Web ß
- ?p?????? ?a? eµp?d?a sta a????t? s?st?µata
- ?atas?e?ast?? p??s??t??? ?a?a?t???st??? as?µßata
µe ???a s?st?µata ??a ?????? a?ta????sµ?? - µp??e? ?a ????? ?aµ???te?? ap?d?s?
- ??ade?a ?????t?s? p??t?p???a??? ??se??
15? e?????? t?? Internet
- ???? sta a????t? s?st?µata ??e? ?µa?? e?????? ta
te?e?ta?a 30 ?????a - ?????? ?p??es?e? ßas?sµ??e? se ?e?µe?? Telnet,
NetNews - ?? s??e?e?a multimedia Web
16?e???? ap? ta p??t?pa t?? d?ad??t??? a?
17?e???? ap? ta p??t?pa t?? d?ad??t??? ß?
18????te?t?????? Web
- ???f??e? eta???e? s??e?sf????? se d?af??et????
?µ?de? standards - To Internet Engineering Task Force (IEFT) e????e?
t? TCP/IP, SMTP, MIME, SSL - To World Wide Web Consortium (W3C) af??? sta URL,
HTTP, HTML - Epe?d? ta standards e??a? a????t?, ??e? s?ed?? ??
eta???e? p?????? s?µßat? p?????ta - ??a ?p?????? f????? ??se?? ??a a??pt??? web
efa?µ????
19?e???????e? a??pt???? efa?µ???? Web
20??sa???? st?? e??t?ta
- ??sa???? st?? ßas???? te???????e? ??a efa?µ????
Web - ??sa???? st?? standard web a???te?t?????
- ?????f???e? ??a PERL, CGI, JavaScriptTM, s??des?
µe ß?se?? de?µ????, JavaTM ?a? ActiveX - S??e??as?a t?? pa?ap??? te?????????
21?as??? a???te?t????? Web a?
- ? a???te?t????? pa???e? t? s??d?? s??des??
d?af??et???? tµ?µ?t?? - ??a ?a?? s?ed?as? a???te?t?????? e??a? e?????t?
?a? epe?t?s?µ? - Web a???te?t?????? client ep???????e? µe server
- ???t?????? ep????????a? TCP/IP
- TCP/IP af??? st? µetaf??? ded?µ???? (e?asf???s?
????? µetaf????)
22?as??? a???te?t????? Web ß?
- Browser ep???????e? µe server µ?s? Hypertext
Transfer Protocol (HTTP) - HTTP af??? st?? e??es? ?a? a???t?s? t??
?at??????? a??e??? - HTTP af??? st?? e?µ??e?a t???
- ?? ????sµ??? Web ep??e?t???eta? st?? p??sßas? ?a?
st?? ep?de??? pe??e??µ???? - To Web a??????e? t? request-response, d??ad? ?
server pe??µ??e? a?t?se?? ap? t??? clients
23?as??? a???te?t????? web ?
- O web browser ??t?e? µ?a d?e????s? (URL) ap? t??
server - To URL µp??e? ?a ???ft??e ap? t? ???st? ? ?a
s?et??eta? µe ??a ?pe?s??desµ? ?.a. - Se ??e? t?? pe??pt?se?? ? web server e?t?p??e?
t? URL t? st???e? µ?s? t?? TCP/IP st?? browser - O browser e?µ??e?e? t?? HTML ?a? ep?de????e? t?
se se??da st?? client - St?? Web server e??a??stata? t? ?at??????
????sµ???, t? ?p??? e?a?t?ta? ap? t?? ????
ded?µ????
24?e???????e? server
- ?? te???????e? p?? af????? t? server,
???s?µ?p????? t? d?s??, t?? ?p?????st??? ?s?? ?a?
t?????? ?p? t? ?e?t??????? t?? server - Common Gateway Interface (CGI), Perl, ?a?
p??sßas? se ß?se?? e??a? s?µa?t???? te???????e?
??a t?? server
25Common Gateway Interface (CGI) a
- ?etaß?ßas? ded?µ???? HTML forms ap? web server se
web browser - CGI pe?????fe? t?? t??p? p?? ? browser ?a? ?
server ?e??????ta? ta ded?µ??a t?p?? form - ????o µ???? epe?e??as?a? ???eta? st? server
- CGI de? e??a? ???ssa p????aµµat?sµ??
- CGI p??pe? ?a e???e? µe ???ssa p????aµµat?sµ??,
p.?. PERL
26Common Gateway Interface (CGI) ß
- To CGI ???s?µ?p??e?ta? se p????? efa?µ????
- ?.?. st? Amazon, ? se??da d?µ?????e?ta? d??aµ???,
(pe???aµß??e? ?a??et?sµ? t?? ???st?)
27S??des? µe ß?se??
- S??des? µe ß?se?? e??a? µ?a s?µa?t??? efa?µ???
??a servers - ??a efa?µ??? ??e???eta? ded?µ??a, ta ded?µ??a
ap????e???ta? se ??a s?st?µa ß?s?? ded?µ????
(DBMS) - ?? ß?se?? ded?µ???? e??a? ???µ? te???????a,
p??sf????? asf??e?a, ???ssa e??t?ap????se?? ?t?. - ??. ?????f???e? ??a pe??te?, pa?a??e??e?,
ap????e???ta? se ??a (DBMS)
28?pe?e??as?a st? Server a
- ??e??e?t?µata
- ?? s?µa?t???? d???e??? e?te????ta? st? server,
?a??te??? ??e???? - ?a??te?? s??t???s?
- ???e??ste?? a?aß??µ?s?
- ?e???e?t?µata
- ??? ? epe?e??as?a se ??a ?e?t???? ?p?????st?
- ?e???? ?p?????st??? ß????
- ?p?t???a t?? server?s??????? ap?t???a t??
s?st?µat?? - ????µ??? ????s? st? d??t??
- H d?ep?f??e?a ???st? a?tap?????eta? µe
ß?ad?te???? ???µ???
29?e???????e? ??a client a
- ??te????ta? st?? client ?p? t? ?e?t??????? t??
client, ???s?µ?p????? t? d?s?? ?a? t??
?p?????st??? ?s?? t?? client - Javascript ?a? VB script e??a? ???sse?
p????aµµat?sµ?? - Javascript ?a? VB script e?s?µat????ta? se
?e?µe?a HTML
30?e???????e? ??a client ß
- ? web browser d?aß??e? t? HTML ?a? ß??s?e?
??d??a µ?a? ???ssa? scripting - ? e?t??es? t?? scripting a?at??eta? st? µ??a??
scripting (scripting engine) - Javascript ?a? VB script e??a? event driven,
(p.?. a?tap???????ta? st? p??t???)?p??
e?d?af????se? efa?µ???? - ???ßasµa st???e??? ???st?, ?p?????sµ??, pa????d?a
- ??d??? ??a d?ad?ast???? efa?µ????? ? ??d??a?
p??pe? ?a e?te?e?ta? st?? client
31??e??e?t?µata/?e???e?t?µata client te?????????
- ??e??e?t?µata
- ??µet???e?s? t?? epe?d?se?? se p??s?p?????
?p?????st?? - ?ata?aµ?µ??? epe?e??as?a?e???sta s?st?µata
- ?e??s? ?????f???a? st? d??t??
- ??ep?f??e?a ???st? ? ??????? ap????s?
- ?e???e?t?µata
- ?p??e?a e?????? t?? p????aµµat?st?, µp??e? ?
efa?µ??? ?a t???e? se ß?ade??/pa?a?? ?e?t???????
s?st?µa clients - ?a?a??? browsers, de? ?p?st??????? t?? ??e?
te???????e
32S??d?asµ?? te?????????
- ??e? ?? efa?µ???? web apa?t??? ?a? client ?a?
server - p.?. ? browser, ??t?e? URL ?a? ? server
ep?st??fe? t? s?et??? se??da - St? s?ed?as? efa?µ???? web µp????? ?a s??d?ast???
HTML, JavaScript, CGI µe Perl ?a? s??des? µe
ß?se??
33S??d?asµ?? te?????????/se?????
- HTML forms, ???s?µ?p?????ta? ??a s??????
ded?µ???? ap? t? ???st? - JavaScript, st?? client e????e? t?? ????t?ta t??
ded?µ???? t?? ???st? - CGI p?????µµata µe Perl st?? server, ??a
pe?a?t??? ??e??? ????t?ta? - S??des? µe ß?s? ded?µ???? st? server, p???e?µ????
?a a?a?t????? ?? s?et???? p????????e? ? ?a
ap????e?t??? ???e? - ?p?p???? CGI p?????µµata st? server?et??µas?a
s?et???? apa?t?se?? st? ???st?
34Java a
- Java e??a? ???ssa p????aµµat?sµ??, (Sun
Microsystems) - ??te?e?ta? se d??f????? ?p?????st??, a?e?a?t?t??
?e?t???????? (?a??? ?a? se s?s?e???) - ???a??? ??d??a? µetat??peta? se d?ad???
- ? d?ad???? e??a? a?e???t?t?? t?? ?p?????st?
- ? Java Virtual Machine (e?d??? se ???e
?p?????st?) e?te?e? t?? d?ad??? ??d??a
35Java ß
- ? Java µp??e? ?a t???e? ?a? st?? client ?a? st??
server - St?? browser t?? client, p?????µµata Java
?????ta? applets - St?? server
- Servlets t?????? ?p? t??? pe?????sµ??? e???
????? p?????µµat?? - ??????? ?? a?e???t?ta p?????µµata
36ActiveX
- ??a?s?? ????????s?? efa?µ????
- ?? efa?µ???? ???f??ta? se ??p??a ???ssa
p????aµµat?sµ?? - ????? st? ActiveX, ?? efa?µ???? ep?????????? se
??a d??t?a?? pe??ß????? - ActiveX, t???e? ?a? se server ?a? se client
- ActiveX, ap? Microsoft ?a? ßas??eta? st?
Component Object Model (COM)
37Applets
38Web Servers ?a? ?TTP
39??sa???? st?? e??t?ta
- ??sa???? st? ßas???? ?e?t?????e? t?? Web sever
- ??sa???? st? ßas??? p??t??????, HTTP
40Web servers
- Web server
- ????sµ??? se ?p?????st?
- ?p?????st?? ep???????e? µ?s? TCP/IP
- ? ?p?????st?? µp??e? ?a e??a? p??s?p???? ? ??a
ta??tat? pa??????? s?st?µa
41????? Web Server ?a? Port 80
- ? web server t???e? ??a at??µ??a ß????
- ?e??µ??e? ??a a?t?se?? st? ???a 80
- T??e? e??a? d??d?? ep????????a? µe t? d??t??
- ????? e?t?p?se? a?t?s?, e?e???p??e?ta?
- ???spa?e? ?a e?t?p?se? t? Uniform Resource
Locator (URL) p?? ??t????e - ?a? t? st???e? st?? a?t??µe?? µ?s? TCP/IP
- ?????!
42????? Web Server, p??ß??µata
- ?? de? µp??e? ?a e?t?p?se? t? ??t??µe?? a??e??
µ?s? t?? URL - 404 File Not Found
- ?? de? ??e? ?de?a ?a ste??e? t? a??e??
- 403 Forbidden error
- ?? ??a p??e ?a??
- 200 OK, d
- St???e? t? a??e??, se??da
43????? web server ß
- ??? t? a?t??µe?? URL e??a? p????aµµa t?te
- ? web server t? e?te?e?
- St???e? t?? ???d? t?? p?????µµat?? st?? client
- ??? t? URL s?et??eta? µe ??a p????aµµa, t?te t?
p????aµµa ?a e?te?este? ???s?µ?p????ta? t? URL ??
e?s?d? - ??? t? URL p???e?ta? ?a ???e? parse, o server
a????e? t? a??e?? ?a? ????e? ??a s?et???? e?t????
44HTTP, t? e??a?
- To HTTP e??a? p??t??????
- ???sd?????e? ?a???e? ep????????a? µeta??
client/browser ?a? web server - HTTP, GET e??a? ? a??? ep????????a?
- F??e µ?? ??a a??e??/web se??da
- ???pe? ?a p??sd????ste? ??a domain name, p?.
www.reuters.com, ??a ?a pe??se? st? TCP/IP - ?ta? ???e? t? a??e?? te?e???e? ? ep????????a
45HTTP pa??de??µa a
lthtmlgt ltbodygt lth1gtHello HTTPlt/h1gt ltcentergt
ltpgtThis page has been... ltpgt The page makes
reference to one image and not much else. It's
solely for teaching about HTTP. ltpgtltimg
src"images/sun-logo.gif" alt"Sun Logo"gt
lt/centergt lt/bodygt lt/htmlgt
- ???a??ete st? URL httptest.html
- ?e?te ta pe??e??µe?a t?? se??da?
- ?e?µe??, µe html ?a? µ?a e????a
46?a??de??µa s??des?? ß
- ???ta a????eta? µ?a s??des? µe t? www.sun.com
- TCP/IP p??spe???e? t?? Domain Name Server (DNS)
- O DNS µetat??pe? t? www.sun.com se µ?a d?e????s?
t?? e?d??? p?. 128.138.178.12 - ?e????e? µ?a s??des?
- ?? TCP/IP f???t??e? ?ste ? s??des? ?a e??a?
a???p?st? - ?? HTTP ??e???eta? t? ?p?st??µa t?? TCP/IP
47??t?s? HTTP client/ browser
??t?s? get st?? the server ??a t? p??? a??e?? ?a
a?a?t?se? GET httptest.html HTTP/1.0 ??e? st??
server ?a µ?? ste??e? t? a??e??, a? de? ??e?
a????e? p??sfata If-modified-since Wed, 19 Jan,
2004, 135959 GMT O browser d????e? ?t? e??a? ?
Netscape version 7, p?? t???e? st?
solaris User-agent Mozilla 7 for Sol 7 ??
ep?µe?e? d???se?? ???e st? server t? e?d???
a??e?a µp??e? ?a ?e???ste? ? browser (d??.
?e?µe??, html, gif, jpeg ) Accept text/plain
Accept text/html Accept image/gif Accept
image/jpeg
48?p??t?s? ap? http server
- ?a?t?t?ta t?? server
- Server NCSA/1.5
- ?µe??µ???a ?a? ??a ap??t?s??
- Date Tue, 19 Jul, 2004 140001 GMT
- O server p????f??e? t?? client ??a t? e?d?? t??
?e?µ???? - Content-type text/html
- Specifies the length of the document
- Content-length 313
- ?e? ?p???e? e?d??? ??d???p???s?
- Content-encoding none
- ??e? st?? browser, p?te µetaß?????e t? a??e??
st?? server - Last-modified Thu, 20 Jul 2004 000000 GMT
- ??a ?e?? ??aµµ?, ??a t? d?a????sµ? HTTP header
(?? pa?ap??? ??aµµ??) from the document itself
(all of the lines below) - The entire HTML document as it is sent to the
browser - lthtmlgt ltbodygt lth2gtHello HTTPlt/h2gt
- ltcentergt
- ltpgtThis page has been transmitted to you from
- the Sun web site in Broomfield, Colorado, USA.
- ltpgtThe page makes reference to one image and not
much else.
49??p?? pe??e??µ???? (content type)
- t? content-type, p??sd?????eta? ap? t? server
- Content-type, ?a?????e? t?? t?p? pe??e??µ????
se??da?, - p.?. text/html ??a se??da ?e?µ???? html
- image/gif ??a e????a t?p?? gif
- ?? p??t?p? ??a content-types e??a? t?
Multipurpose Internet Mail Extension (MIME) - S??d?e? t? file extension µe ??a t?p? a??e??
50??p?? MIME
51Browser/client
- ?aµß??eta? ? HTTP ap??t?s? ap? t? server
- ?? TCP/IP ??e??e? ? s??des?
- O server e?a??????e? ?a pe??µ??e? a?t?se??, st??
???a 80 - ? browser, d?aß??e?/e?µ??e?e? t?? html se??da
- H p??a??da (tag) lth1gt, d????e? ep??efa??da, ?a? ?
browser t?p??e? t? a?t?st???? ?e?µe?? µe µe??????
?a?a?t??e? - ltpgt d????e? ??a??? ??a? pa?a???f??
- lt?mggt d????e? t?? ?pa??? e????a?
52S?µp????µat??? a??e?a
- ? p??a??da ltimggt d????e? ??a s?µp????µat???
a??e?? - ? browser ?a?e? t? TCP/IP ?a a????e? µ?a ??a
s??des? - ????? ep?te???e? ? s??des?...
- Fe??e? HTTP, GET a?t?s? (ap? client) st? SUN
- ?a??µ??a d?ad??as?a µe t?? p??????µe??
53Se????? HTTP
- S??des? µe DNS server
- ?etat??p? Domain Name Service se d?e????s? IP
- ???a??d??s? s??des?? TCP/IP µe ap?µa???sµ???
?p?????st? - Sp?s?µ? t?? µ???µat?? se pa??ta
- ???µ?????s? t?? pa??t?? µ?s? d??t???
- ??t?s? HTTP GET
- ?p??t?s? HTTP
- ??e???? ???? ?a? sfa?µ?t?? ap? TCP/IP
- H se??da ep?de????eta? st?? Browser
- ?p?p??s?ete? a?t?se?? HTTP GET
- ?p?p??s?ete? apa?t?se?? HTTP
54S????asµ?? HTTP
- ??e??e?t?µata
- ?? HTTP de? ??µ?ta? t?? p??????µe?e? a?t?se??
- ?p??e? ?a ?e???ste? e?at?µµ???a a?t?se??
- ?e???e?t?µata
- ???e? se se??de? p?? ap?te????ta? ap? p????
tµ?µata - ?.?. 20 e????e? st? se??da, ??e?????ta? 21
a?t?se?? ?a? 21 a?tap????se?? - ??e???eta? e?d???? s?ed?asµ?? ??a ?a e??a? ???????
55Perl ?a? CGI
56??sa???? st?? e??t?ta
- CGI ? p???? a?ept??µ??? a???te?t????? WEB
efa?µ???? - ?e????af? t?? CGI standard.
- ???p?? ?e?t?????a t?? CGI.
- ?? p???? ???s?µ?p????µe?e? ???sse? ??a CGI.
- ???pt??? µ????? CGI p?????µµat?? µe PERL.
- ?etaß??t?? pe??ß?????t?? CGI ?a? p??sp??as? t???
ap? t?? Perl.
57??sa???? st? Common Gateway Interface (CGI) a
- ?? CGI e??a? t? pa?a??te?? ?a? ???µ?te?? standard
??a a??pt??? efa?µ???? - S??d?e? se??de? web µe e?te??s?µ? ??d??a
- ?e?t????e? µe C, C, Perl, Java ?t?.
- ???sd?????e?
- ?? p??asµa ded?µ???? ap? web browser st?? server
- ??? ? server µetaf??e? ta ded?µ??a sta d??? t??
p?????µµata - ??? µetaf????ta? ded?µ??a st?? Web browser
58??sa???? st? Common Gateway Interface (CGI) ß
- ?? p????aµµa CGI ???e? t? µe?a??te?? µ???? t??
e??as???. - ? server d?a ?? e?d??µes?? d?e?pe?a??t??.
- ?p?????? t??a tµ?µata se ???e d?ad??as?a CGI
- Web browser p?? e?te?e?ta? st?? client
- Web server
- ?????aµµa CGI p?? e?te?e?ta? st?? server.
59To CGI e? d??se?...
- O browser st???e? st?? server ??a URL p??
pe???aµß??e? ??a p????aµµa CGI. - O server e????e? a? t? URL e??a? e?te??s?µ?.
- ?e????e? t? p????aµµa ?a? µetaß?ß??e? ??p??e?
µetaß??t?? µa?? µe d??f??a ???a ded?µ??a. - ?? CGI e?te?e?ta? ?a? ?atas?e???e? µ?a ap??t?s?,
?p? µ??f? se??da?. - ? server µetaß?ß??e? t? se??da st?? client
browser - ? client browser ep?de????e? t? se??da, ?? a??e??
html.
60?a?ade??µata ???ss?? p????aµµat?sµ?? ??a CGI
61?e?? Perl
- ??µ?f???? ???ssa ??a efa?µ???? CGI.
- Perl interpreted
- ???feta? t? p????aµµa ?? ascii
- ?etaf???eta? se ??d??a µ??a??? d??aµ???
- S???pe?a e?e????a
- St?? Perl ?p?????? pe??ss?te??? t?? e??? t??p??
?a ???e?? ??t?
62??e??e?t?µata Perl
- ? Perl ??e? e?a??et???? d??at?t?te? ?e???sµ??
?e?µ????. S?????? a?t? apa?te?ta? ap? p?????µµata
CGI - H Perl e??a? s?et??? e?ast??? ?? ???ssa
- ?e? apa?te?ta? d?sµe?s? µ??µ?? ??a µetaß??t??
- ??????p??e? µe t?µ? 0 t?? µetaß??t??
-
63?? p??t? p????aµµa CGI !
- !/usr/local/bin/perl -w
- print "Content-type text/html\n\n"
- print "lthtmlgt\n"
- print "ltbodygt\n"
- print "ltpgtHello World!lt/pgt\n"
- print "lt/bodygt\n"
- print "lt/htmlgt\n"
- ? p??t? ??aµµ? ?a?e? t?? perl intepreter
- H de?te?? ??aµµ? e??a? e?d???. ??µ?????e? t?
http header (ep??efa??da) ?a? p??pe? ?a
a??????e?ta? ap? ?e?? ??aµµ?. - ?? ?p????pe? ??aµµ?? t?p????? ??a html a??e??
- ? ?a?a?t??a? \n d????e? ??a ??aµµ? ?a? ??e???eta?
µ??? ??a t? e?a?????st?
64CGI ?a? http header
- O http header e??a? ??s?ast???? se p?????µµata
CGI. - ????? header o web server de? ???e? t?p?ta ??a t?
e?d?? t?? ded?µ???? p?? ?a ep?st???e?. - ? web browser ?a p??e? µ???µa ??????
- ?? p???e?µ??? ? header ?ee? ?t? t? a??e?? e??a?
t?p?? html - ?? ?a de? st?? browser o ???st?? a? a?t?
text/html ??e? text/plain
65CGI µ?sa ap? html
- ?? CGI p?? e?date, e??a? ap???stat?
- ?e? d??eta? e?s?d? ap? ???st?
- ?e? epe?e????eta? p????f???e?
- ???p?? ???s?? t?? CGI p?????µµat??
- lthtmlgt
- ltbodygt
- lta href"hello.cgi"gt??t??ese t? Hello World
p????aµµa CGI lt/agt - lt/bodygt
- lt/htmlgt
66?etaß??t?? pe??ß?????t??
- ?etaß??t?? pe??ß?????t??, µ???? t?? CGI standard
- T?? ?a?????e? ? web browser, ?a? ? web server
- ?a???????? t? host name, ip address, software
version
67?a??de??µa µetaß??t?? pe??ß?????t?? a
!/usr/local/bin/perl -w print "Content-type
text/html", "\n\n" print "lthtmlgt", "\n" print
"ltbodygtlth1gtCGI Environment Variableslt/h1gtltpregt",
"\n" print "Server Host Name ",
ENVSERVER_NAME, "\n" print "Server Software
", ENVSERVER_SOFTWARE, "\n" print "Server
Protocol ", ENVSERVER_PROTOCOL, "\n" print
"Browser Software ", ENVHTTP_USER_AGENT,
"\n" print "Browser IP Addr ",
ENVREMOTE_ADDR, "\n" print "Request Method
", ENVREQUEST_METHOD, "\n" print "Content
Type ", ENVCONTENT_TYPE, "\n" print
"lt/pregtlt/bodygt", "\n" print "lt/htmlgt", "\n"
68?a??de??µa µetaß??t?? pe??ß?????t?? ß
- O p??????µe??? ??d??a? ap????e?eta? se ??a CGI ?
PERL a??e?? st? server. - ??a se??da html µp??e? ?a ??e? s??desµ? se a?t?
t? a??e?? - O web browser ?a de??e? t?? t?µ?? t?? µetaß??t??.
69?a??de??µa µetaß??t?? pe??ß?????t?? ?
- ?? p??te? ??aµµ?? ?a???? t?? Perl Interpreter ?a?
?atas?e?????? t?? http header. - ?? ep?µe?e? ??aµµ?? t?p????? µetaß??t??
pe??ß?????t?? - ?? t?µ?? t??? ??????ta? ap? t?? web browser
- ???e? t?µ?? ??????ta? ap? t?? web server
- ???spe??s?µe? ap? µ?a d?µ? Perl p?? ???eta?
associative array ENVvariable_name - ? p????? pe????af? t?? CGI e??a? st?
http//hoohoo.ncsa.uiuc.edu/cgi/interface.html.
70???at? ?a? ad??aµa s?µe?a t?? Perl
- ? Perl ???s?µ?p??e?ta? e?????? µe???? ?p?st?????
- ?e???e? d??at?t?te? ?e???sµ?? ?e?µ???? ?
???s?µ?tat? ?? e??a?e?? se web efa?µ???? - ???? e????? st?? e?µ???s? se s??s? µe C/C
- ??at??eta? d??e??
- ??e? ?µ?? ß?ad?te???? ??????? e?t??es?? se s??s?
µe C/C
71Perl, CGI, HTML
72??sa???? st?? ???t?ta
- S??ta?? ßas???? HTML forms
- HTML form elements ?a? CGI program variables
- ?????aµµat?sµ?? ap??? HTML form p?? s??e????eta?
µe ??a CGI script - ????d?? post, get
- ??e??e?t?µata µe???e?t?µata a???te?t?????? SAPI
?a? CGI
73 ???L forms ?a? CGI
- ?? HTML forms ???s?µ?p?????ta? ??a s??????
ded?µ???? ap? t? ???st? - ?????ta? ded?µ??a ap? t? ???st?
- ??a??t??? ???µata µetaß??t?? sta ded?µ??a p??
d??e? ? ???st?? - ?a???????? t? µ???d? p?? ?a ???s?µ?p????e? ??a ?a
pe?ast??? ded?µ??a ap? t?? web browser st? CGI
p?? t???e? st?? server - ?a???????? t?? e????e?e? p?? ?a ?????? ?ta? ?
???st?? ?p?ß???e? ta ded?µ??a (submit)
74??a ap?? HTML form a
- lthtmlgt
- ltbodygt
- lth1gtTesting 123lt/h1gt
- ltform action"test5.cgi" methodgetgt
- ltpgtEnter your favorite greeting, e.g. Hello
- ltinput typetext name"greeting" size10gtltbrgt
- ltpgtEnter your first name
- ltinput typetext name"firstname" size10gtltbrgt
- ltinput typesubmit value"Run CGI Program"gtltbrgt
- lt/formgt
- lt/bodygt
- lt/htmlgt
75??a ap?? HTML form ß
- lthtmlgt, ltbodygt ?????µa ?a? ??e?s?µ?
- ltpgt, lth1gt e?a?????st? ?e?µe??
- ltinputgt tags, e?s?d?? ded?µ????, p????? t?p??
p.?. - ??s?d?? ded?µ????
- Typetext, d??ad? e?s?d?? ?e?µe??
- Namefirstname, d??e? ???µa sta ded?µ??a
- ?p?ß??? ded?µ????
- ? ???st?? ???e? ???? se ??a ???µp?
- ??te?e?ta? t? a?????? CGI p????aµµa st?? Server
76CGI se HTML forms
77FORM methods/actions
- ????d?? GET, actione?t??es? CGI a??e???
test5.cgi - ltform actiontest5.cgi methodgetgt
- ????d?? POST, actione?t??es? CGI a??e???
test5.cgi - ltform actiontest5.cgi methodpostgt
- ?? ???sµ??, (a? de? p??sd????ste? ? µ???d??), ?
browser ep??. GET
78????d?? GET a
- ? browser µetaß?ß??e? ta ded?µ??a t?? ???st? ??
µ?a s?µß???se??? - St? pa??de??µa µa?, ????µe
- ?? d?saµe ?? greeting to Hello ?a? ?? ???µa t?
G Papadopoulos - http//www.testing.org/test5.cgi?GreetingHellona
meGPapadopoulos - Greeting, name e??a? ???µata µetaß??t??
- ?a ?e?? ??d???p??e?ta? ??
- ?a ???µata µetaß??t?? ???????ta? µe t?
- ?? URL ?????eta? µe ?, ap? ta ?p????pa
79???sp??as? ded?µ???? CG? µe PERL
- To ????sµ??? t?? web server e?te?e? t? p????aµµa
CGI - ???? ?µ??, ?p???e? p??et??µas?a
- ?etaß??t?? pe??ß?????t??...
- To CGI p??pe? ?a d?e?e???se? t? ded?µ??a e?s?d??
t??
80 Demonstrates a way to connect
HTML form to CGI program
Get input from HTML form and parse into
namevalue pairs HTML form uses the GET method,
so access from QUERY_STRING access user data
in QUERY_STRING buffer ENVQUERY_STRING
Split the name/value pairs on '' creates
array called _at_pairs with namevalue pair _at_pairs
split(//, buffer) Parse _at_pairs determining
name value for each ltformgt variable loop
thru _at_pairs array, decoding encoded data Foreach
pair (_at_pairs) split name and value and put
into scalar variables (name, value)
split(//, pair) convert plus signs back to
spaces as entered by user value tr// /
convert encoded hexadecimals back to ASCII as
entered by user value s/(a-fA-F0-9a-fA-F0
-9)/pack("C", hex(1))/eg set up hash for
ltformgt data inname value Now all
ltformgt variables are in the in associative array
81?p?te??sµata t?? ??d??a
- ??e? ?? µetaß??t?? p?? pa??s?e ? ???st?? e??a?
st? in array - ? t?µ? t?? µetaß??t?? greeting/name, µp??e? ?a
a?a?t??e? ?? ingreeting / inname
82?pe?e??as?a CGI ?a? PERL
- CGI a?a??e? e?se???µe?a ded?µ??a
- ?p?st??fe? ap?te??sµata a????s??
- ?p????e?e? ta ded?µ??a se log a??e?a, ??a
- ?p??e? ?a s??de?e? p????aµµa µe ß?s? ded?µ????
83?p?st??f? ded?µ???? ???st? se ??a se??da
- Create the "virtual" web page complete with
partial HTTP header - generate a valid content type header for use by
HTTP - print "Content-type text/html\n\n"
- generate the opening HTML tags for the user
response - print "ltHTMLgtltHEADgt\n"
- create a title for the response page
- print "ltTITLEgtTesting 123lt/TITLEgt\n"
- close the HTML head and begin the body
- print "lt/HEADgtltBODYgt\n"
- create a title for the response page
- print "ltH1gtTesting 123lt/H1gt\n"
- start a new paragraph the response page
- print "ltPgt\n"
- echo the greeting and name entered by the user
- print param("greeting"), param("name"), "!
ltbrgt\n" - use an environment variable in the response
- print "Your IP address is ENVREMOTE_ADDR\n"
- finish the response page print
"lt/BODYgtlt/HTMLgt\n"
84S????asµ?? ??d??a
- ?? print ??aµµ?? d?µ???????? ??d??a HTML, µe
???st? HTML tags - ?? param(greeting) ?a? param(name)t?p?????
t?? e?s?d??? p?? ?d?se ? ???st?? - ?? e??e ??afe? ? ??d??a? ?e???sµ?? pa?aµ?t??? p??
pa?a??saµe, a?t? ??a param(greeting) ?a?
param(name)?a ???faµe print "ingreeting
inname! ltbrgt\n"
85Server Application Programming Interfaces (SAPI)
- SAPI, µetaß?ßas? ded?µ???? ap? browser se ??a
p????aµµa st?? server - SAPI, e?a??a?t??? t?? CGI, ?a? ta??te??
- SAPI, de? e??a? f???t?, p???? standards
- CGI, ???µ? p??t??????
- SAPI ??a efa?µ???? ?????? ap?d?s??
86???e? e?a??a?t???? ??se??, ??a CGI
- ?a??µ??a ?????? µe SAPI
- ASPActive Server Pages, Microsoft, s?ed?asµ???
?????? ??a p?????ta Microsoft - Servlets, Sun, f???t?