Professional Documents
Culture Documents
Web Server
Client
1 Internet Banking
Internet Client-Server Systems
Client
Web Server
GET foo.html
PC-1 Web Server
Foo.html
Request 2
Web Servers
◆ Most web servers are very simple. They
just return files to the PC that requests it
Request file
Retrieve file
Send file
Dynamic Web Pages
Request service
Do Computation
Generate HTML
page with results
of computation
Return dynamically
generated HTML file
CGI and Web Forms
◆ How to write the HTML that sends data to
the server?
HTTP
SERVER
stdin
QUERY_STRING
CONTENT_LENGTH
Request Method: Get
Request Resource
Method Query
Name
String
CGI URLs
◆ There is a mapping between URLs and CGI
programs provided by a web server. The
exact mapping is not standardized (web
server admin can set it up)
◆ Typically:
➢ requests that start with /CGI-BIN/ , /cgi-bin/
or /cgi/, etc. refer to CGI programs (not to
static documents).
CGI Programs
◆ When the user hits the “submit” button
the data is sent to the web server
◆ The CGI program that handles it on the
web server is specified in the HTML
Form tag
firstName=lee
middleName=harvey
lastName=oswald
CGI Programs
◆ Strengths:
➢ A simple method to send data to the server.
➢ Dynamically generates HTML pages.
➢
◆ Weaknesses
➢ All the processing happens on the server.
➢ Takes time to launch the CGI process on the
server.
➢ Use the process, instead of thread.
Web Forms
◆ Overview of Web forms
◆ HTML form components
◆ GET & POST methods
◆ Server-side processing with forms
CGI-based Web Application
HTT Request
HTTP Document
Web Browser Web Server
Get Data
CGI Scripts/
Applications Database
Return data
Form Interaction with CGI
Web Browser Web CGI
Server Program
User requests form
Network Server
Forms
◆ Forms work in a different and slightly more
complex way than standard HTML pages.
◆ Forms consist of a number of separate data entry
components such as menus and text areas.
◆ The user can select different options from the menus
and enter text in the text entry fields.
◆ A single form can contain many text entry fields
and/or many menus.
◆ To differentiate the menus and text areas from each
other each one is given a unique name, selected by
the Web form designer.
HTML Forms
When the user clicks the submit button, the set of variable
names & corresponding values are sent to the Web server
in a HTTP request.
The Web server can extract the set of variables & values
from the HTTP request, and can do something with them...
Example for HTML Form
<html>
<head> Note that this form
<title>Query Form</title> contains two variables
name & id
</head>
<body>
<h2>Query Form</h2>
<form method="GET” action="doquery.php”>
<p>Your name: <input name="name" type="text" size=30></p>
<p>Your ID: <input name="id" type="text" size=15></p>
<p><input type="submit" value="Submit your query"></p>
<p><input type="reset" value="Clear your query"></p>
</form>
</body>
</html>
Example for HTML Form
◆ Two options:
➢ GET: pass the data in a HTTP GET request
➢ POST: pass the data in a HTTP POST request
◆ http://www.yorku.ca/jhuang/doquery.cgi?name=joe+bloggs&id=1234
◆ Note how the variable names & values are appended to the URL.
Any spaces in a value are converted to +.
Form Actions
◆ The action attribute on the form tag specifies what the
Web server should do with the form data.
◆ Common options:
➢ email the data to someone [the mailto action]
➢ pass the data to a script or program
◆ For example, the CGI script could use the name & id to
look up student info in a database.
Form Actions
◆ <form method="GET" action="mailto:jhuang@yorku.ca">
◆ Until you can actually use scripts on the server, use the
mailto action. It operates in the same way as the mailto that
you have used in the HTML document.
◆ POST:
➢ REQUEST_METHOD is “POST”
➢ CONTENT_LENGTH is the size of the query
(in bytes)
➢ query can be read from STDIN
HTTP Form Processing
1. user fills in form &
clicks submit 2. Browser sends GET
http://www.yorku.ca/jhuang/doquery.cgi?name=joe+bloggs&id=1234
4. server sends
5. Browser script results to 3. server runs
displays the Browser the script
script results* doquery.cgi
passing form
internet data to it
Password field
Radio buttons
Drop-down list
Check boxes
Text area
Buttons
Form Processing & Results
◆ The easiest way to deal with form data is to simply email it to an
email address using a mailto form action:
◆ The old way is to use a so-called CGI Script, usually with a URL
something like:
SSI
WWW
CGI WWW server
CGI HTTP client
program
API
script
(embedded
in HTML)
Java
other Java applet
program servlet
(application )
SML
)
Some History
◆ SGML
◆ HTML
HTML - Disadvantages
◆ Limited tag set
◆ Can’t separate the presentation from content
◆ Can’t define structure of contents
XHTML
)
XHTML Basics
◆ Very few real changes from HTML
◆ But more strict
<body>
<p>Welcome to XHTML!</p>
</body>
</html>
Images
The value of the src attribute
)
XML Introduction
◆ The Extensible Markup Language (XML) is a document
processing standard proposed by the World Wide Web
Consortium (W3C), which is related to Standard
Generalised Markup Language (SGML).
◆ Possible to search, sort, manipulate and render XML
using Extensible Markup Language (XSL).
◆ Highly portable
◆ Files end in the .xml extension.
XML & W3C
• XML has been in development since the 1960s through its parent called
SGML (Standard Generalized Markup Language) which is also the parent for
HTML
- www.w3.org/xml
- www.xml.com/axml/axml.html (annotated version)
XML-related Technologies
◆ DTD (Document Type Definition) and XML Schemas are
used to define legal XML tags and their attributes for
particular purposes
<passport_details>
<last_name>Smith</last_name>
<first_name>Jo</first_name>
<first_name>Stephen</first_name>
<address>
<street>1 Great Street</street>
<city>GreatCity</city>
<state>GreatState</state>
<postal_code>1234</postal_code>
<country>GreatLand</country>
<email>jo@theworldaccordingtojo.com</email>
</address>
</passport_details>
XML Examples
◆ XML Source File
➢ http://www.yorku.ca/jhuang/xml/04.adhoc.topics.xml
http://www.xml.com/programming/