PREV | TOP |
NEXT Advanced Topics HTTP Servers CGI Fill-out Forms Processing Form Data Imagemaps Creating Dynamic Documents |
Now we discuss some of the more sophisticated aspects of the World Wide Web. We reserve this for now because some of it requires you to have access to certain programs and files on a computer system which is running the HTTP server.
First, we will talk about the HTTP server software, the heart of WWW operations. Then we will go onto CGI (Common Gateway Interface) which allows browser to interact with programs as well as simple HTML files. Finally we will cover imagemaps.
HTTP Servers
A HTTP Server is simply a program which runs on a computer and handles requests for information from other computers on the Internet. At time of printing, there are dozens of public domain and commercial Web server software packages available. While Unix is the operating system platform most often used for HTTP servers, there is server software solutions for a variety of other systems as well.
While it is beyond the scope of this book to cover the intricate details of the installation, configuration and maintenance of a HTTP server, we do provide information about where the software is available and how to find such information yourself.
This section will cover some of the more popular servers: NCSA, CERN, and Netscape's Netsite.
NCSA
NCSA's server software is, by far, the most common HTTP server. There is a secure NCSA server available as well.
The NCSA HTTP Server software distribution is available via anonymous FTP at ftp.ncsa.uiuc.edu in the directory /Web/httpd/Unix/ncsa_httpd/.
Information about the server, its installation, and configuration is available at the URL http://hoohoo.ncsa.uiuc.edu/.
CERN
Because the World Wide Web began at the CERN particle physics laboratory, this server software has been around longer than any other. This presents some advantages in terms of reliability and stability. However, the CERN server software is not known for its ease of installation and configuration.
Information about downloading the public domain CERN server software and how to install, configure, and maintain it is available at the URL http://www.w3.org/hypertext/WWW/Daemon/Status.html .
Netscape Netsite
Netscape's commercial servers are very popular for those people who are interested in paying money for Web server software.
At time of printing, Netscape offers two server packages: Netsite Communications Server and Netsite Commerce Server. They are both fully functional HTTP servers which Netscape claims to be very efficient and easy to install. The Netsite Commerce Server is different than the Netsite Communications Server because it adds the Netscape Secure Mode for encrypted data transfer capability for secure financial transactions.
For information about these products see the URL http://www.netscape.com/MCOM/products_docs/server.html or contact Netscape Communications via telephone at (415)528-2555.
CGI
CGI, the Common Gateway Interface, adds a whole new level of functionality to the World Wide Web. CGI allows you to use programs to generate Web pages or to process input information from Web pages, with fill-out forms.
This opens a door to a whole new realm of possibilities for the Web.
Unfortunately, it is beyond the scope of this text to go into great detail about the CGI programs. Our goal is to introduce you to the functionality of CGI so that, when presented with the need to incorporate it into your Web designs, you will understand how it is done.
Most CGI programs are written in C, Perl, or Unix shell script. But most any programming language can be used.
Because of the security considerations involved with letting any anonymous user on the Internet run programs on your computer system, CGI programs are usually kept in one directory which is often only accessible by the system administrator. Unfortunately, this often makes installation and maintenance of CGI programs difficult for the normal user.
There are solutions to this problem, however. One is a CGI program called cgiwrap, which resides in the systems HTTPD cgi-bin directory. It allows normal users on a Unix system to create a directory called cgi-bin in their HTML directory (i.e. public_html/) for the purpose of storing their own CGI programs. With cgiwrap, a user can refer to a script or program in their personal cgi-bin directory by referencing a URL like this:
http://www.netfx.com/cgi-bin/cgiwrap?user=jblow&script=myinfo.pl
What Can I Do with CGI?
While many people can gain an understanding of what CGI is and how it works, it is often unclear what it can be used for.
As stated before, with CGI we can use programs on the WWW server computer to either produce HTML or to process information from fill-out forms, or do both. First we'll look at how we can use programs to generate Web pages for us.
Here is a Unix shell script which tells us the time and date according to the WWW server:
#!/bin/sh
echo "Content-type: text/html\n"
echo "<html><head><title>DATE AND TIME</title></head>"
echo "<body>The date and time right now:<pre>"
date
echo "</pre></body></html>"
This script, when called as a CGI program through the WWW server will produce this output:
There really is no limit to what you can do with CGI. Examples of applications of CGI programs which only generate HTML output:
These are just a small sampling of the possibilities.
When producing output for an HTML browser, it is essential that you include a MIME content type specification as the first line in your output and a blank line after it. For HTML information this should be Content-type: text/html. If you are sending plain ASCII text, this should be Content-type: text/plain.
Fill-out Forms Fill out forms are the current epitome of interaction
on the Web. They allow you to input information into
you browser, which is then fed to a CGI program. The
program may generate some sort of output for you to see,
or it may do something entirely different (i.e. send a
mail message to someone.)
An example of the use of fill-out forms is any of
the search engines on the Web- including those we cover
in the book (see Chapter 3). Let's look at the Yahoo!
When using an input field which is of the type
TEXTor PASSWORD, you can use the
SIZE argument to adjust how wide the input field will appear in the form.
The size is measured in number of characters.
Let's look at Yahoo's search page again.
You will notice, the Yahoo form has several new
page elements which have not been discussed yet: text
input fields, buttons, radio buttons, and selection menus.
Now lets look at some of the HTML used to generate
the Yahoo search form above.
<FORM>
As you can see in the HTML shown, all the fill-out
form elements are place between the
<FORM> and the </FORM> tags.
The <FORM> tag has some arguments which
indicate what is to happen when you attempt to submit the
form to a server.
The first argument to <FORM>,
METHOD, can be set to either POST or
GET. The difference between the two of these is how the information is passed to the
CGI program. When using GET, the data from the form
is sent to the program in an environmental variable
called QUERY_STRING. When you use
POST, the data is sent to the program as standard input to the
program. For general purposes, it is recommended that you
use POST.
The next argument shown, ACTION, indicates the
URL which identifies the location of the CGI program
which will handle the data processing, in this case,
http://search.yahoo.com/bin/search.
<INPUT>
The <INPUT> tag is used for collecting a variety
of different kinds of input.
The TYPE argument to the tag indicates what kind
of input we are collecting with the tag. Here is a list
of possible values for the TYPE argument:
The NAME Argument
Each input tag in a form is usually given a name
with the NAME argument to the
<INPUT> tag. This name becomes some sort of identifier variable to the
CGI program which handles the input. For example, here
we create a text entry field called
fullname:
Let's assume that in the form, we input Joey Jo Jo
Jr. Shabadoo in this input field. When the CGI
program receives the form data, it will create some sort of
relationship which establishes that the information
represented by fullname contains "Joey Jo Jo
Jr. Shabadoo".
The VALUE Argument
This is used to assign a default value to a field.
For example, you could make a radio button already
selected. You could set up a text field to already have text in
it when the form is loaded. When working with a
check-box, use the CHECKED argument instead, to
indicate the check-box should already be checked.
This would create a default value for the name
pizza to be yes.
Other Arguments
When using an input field which is of the type
TEXTor PASSWORD, you can use the
SIZE argument to adjust how wide the input field will appear in the form.
The size is measured in number of characters. This does
not limit the form user to how many characters can
be entered in, just how many characters will be displayed
at one time. You can use the MAXLENGTH argument
to specify the maximum number of characters that can
be entered in a TEXT or PASSWORD field.
The SUBMIT and RESET Types
These are two special TYPE values for the
<INPUT> tag which are used to create special push buttons.
A SUBMIT button is used to send the form data to
the CGI program. Selecting this button is typically the
last thing a person would do in working with a fill-out form.
The RESET button clears all the values in the form
and sets them back to the default values (as specified by
the
HTML code).
You can use the VALUE argument to create a label
for the button:
<SELECT>
The <SELECT> tag allows you to let users choose
from a list of options. The list usually appears as a pull
down menu. This tag is used in Yahoo!'s search form to let
the user specify the number of matches to return.
Unlike the <INPUT> tag, there is a matching
</SELECT> tag which is used to mark the end of the
options list information.
You use the NAME argument with
<SELECT> to give the selection an associated name to be used by the
CGI program.
Each option is listed between the
<SELECT> and </SELECT> tags and enclosed in
<OPTION> and </OPTION> tags:
By default, the browser will usually show the first
option as being the default selection. If you wish to change
the
default selection, include the argument
SELECTED within the <OPTION> tag:
You can change the <SELECT> element from a
pull-down menu into a scrolled list with the SIZE
argument to the <SELECT> tag. If this argument is set to
the value of 1, it will produce a pull-down menu (this is
the default). If it is set to 2 or more, a scrolling menu will
be shown with the value specifying how many
selections will be shown at one time.
The default behavior of the <SELECT>
tag is to allow one item from the options list to be selected. However,
if you use the MULTIPLE argument to the
<SELECT> tag, multiple items in the options list can be selected.
<TEXTAREA>
To gather multiple lines of text input, you can use
the <TEXTAREA> tag. Like the
<SELECT>tag, you must also use a
</TEXTAREA> tag to mark the end of
the element.
You can use ROWS and COLS arguments
with <TEXTAREA> to define the dimensions of the
multi-line text input field.
Unlike with <INPUT> tags, where you can use
the VALUE argument to preset the contents of the
form element, with the <TEXTAREA> element, all you
need
to do is put the data you want to default between
the <TEXTAREA> and
</TEXTAREA> tags.
Remember, also, to use the NAME argument to
assign the input data a symbolic name.
Using Hidden Fields
There are times when you may want to pass
information to a CGI program from a form, but not make the
information available to the user to modify. You can use
the HIDDEN value for the TYPE argument to the
<INPUT> tag to include hidden data in your form:
<input type="hidden" name="access" value="restricted">
<h2>Yahoo Search</h2>
<form method=GET
action="http://search.yahoo.com/bin/search">
Find all matches containing the <i>keys</i>
(separated by space)<br>
<input size=30 name=p> <input type=submit
value=Search> <input type=reset value=Clear> <br>
<dl>
<dt>Find matches in
<input type="checkbox" name=t checked>Title
<input type="checkbox" name=u checked>URL
<input type="checkbox" name=c checked>Comments<br>
<dt><input type="checkbox" name=i > Case
sensitive matching<br>
<dt>Find matches that contain
<dd><input type="radio" name=s value="o">At least one
of the <i>keys</i> (boolean <b>or</b>)
<dd><input type="radio" name=s value="a"
checked>All <i>keys</i> (boolean <b>and</b>)
<dd><input type="radio" name=s value="s">All
<i>keys</i> as a single string
<dt>Consider <i>keys</i> to be
<dd><input type="radio" name=w
value="s" checked>Substrings
<dd><input type="radio" name=w value="w">Complete words
<dt>Limit the number of matches to
<select name=l><option selected>100<option> 200<option>
300<option> unlimited</select>
</dl>
</form>
TEXT Normal text. PASSWORD Same as normal text except letters appear as
asterisks. RADIO A single button, which toggles, to set a value on
or off. CHECKBOX An open box which can be checked on or
off.
<input type=text name=fullname>
Check here if you want pizza: <input
type="checkbox" name="pizza" value="yes">
<input type="submit" value="Send the information">
<SELECT name="icecream">
<OPTION>Vanilla</OPTION>
<OPTION>Chocolate</OPTION>
<OPTION>Strawberry</OPTION>
</SELECT>
<OPTION SELECTED>Chocolate</OPTION>
Enter your comments below: <br>
<textarea name="comments" rows=5 col=60></textarea>
MapThis | http://galadriel.ecaetc.ohio-state.edu/tc/mt/ |
MapEdit | http://sunsite.unc.edu/boutell/mapedit/mapedit.html |
HotSpots | http://www.hooked.net/users/1auto/hotspots.html |
Macintosh
Mac-Imagemap | http://weyl.zib-berlin.de/imagemap/Mac-ImageMap.html |
WebMap | http://www.city.net/cnx/software/webmap.html |
Unix
MapMarker | http://www.dl.ac.uk/CBMT/mapmarker/HOME.html |
MapEdit | http://sunsite.unc.edu/boutell/mapedit/mapedit.html |