SCOUG OS/2 For You - June 1997
Programmable Web
This article continues a series on the elements of web page
construction. In recent articles we've focused on static pages. Like
a book or a magazine, many web sites use the digital equivalent of
printed pages. Sometimes they seek to inform, sometimes to impress
with pretty pictures, but often they "just sit there." In the few
years the web has been around, remarkable advances have been made in
the underlying technologies of the web. Some of the more exciting
techniques use programmed functions to provide excitement and
interactivity to your web pages.
There are two basic ways to program a web page - at the server or in
your browser, called "client side." The programming details are
complex, and will require a lot of effort to master. But there are a
few fundamentals and canned programs which you can apply easily.
We'll explore some of them here.
Forms
The earliest attempts at web programming were to get user inputs from
a web page. The HTML tag <form></form> gives a structured way to
format user inputs and pass them to a program running on the web
server. Forms give the web author several structured devices to ask
the visitor for information. This information is then passed back to
the server for processing. Let's sample a few of those tags.
Try this script. Type it and save it as form.htm, and open it with
your web browser. It will perform correctly in Netscape, but you can
add other HTML features as you see fit.
This form will give you a pair of "radio" buttons to select your OS/2
version, a list box to "select" your access type, a "text" area to
enter free-form text, and a "submit" button to send your data to the
server. Go ahead and click the Send button. It will try to find a
non-existent program, so nothing will execute, but, look at the
Location field of Netscape. You'll see your path, plus something like
?ver=4&access=Dial-up&fave=Internet+SIG+web+site/
This shows how the "Get" method packages the inputs to send them to
the server. A program would then parse the pieces of this input,
process them, and send a new web page in response.
CGI
The standard API or interface for web server programs is called Common
Gateway Interface, or CGI. CGI is a specification used by web servers
to describe how they interact with local programs called by remote
browsers. You need special permission to install CGI programs on a
web server and your administrator may want evidence of your
proficiency first. Or, if you use a commercial internet service
provider, they might want more money to cover reviews of your
programs. You might want to practice with a server such as Apache for
OS/2 on your local computer. Your programs can be written in any
language that runs on your server. Extensive libraries of canned
programs are available in the Perl language, but you can program in
REXX, C, even Java. We'll go into more detail on CGI programming in
future articles.
Java "Clients"
We mentioned the other way to program your web pages is with client
side programs. This involves sending the program back to the
visitor's browser. You have to be sure to pick a program language
your visitor is likely to understand. The modern standards for this
are Java and Java Script. Netscape is able to interpret both of these
languages and perform the commands it is sent by the server. How to
program these functions will also be deferred to a future article.
For now, let's see how to use Java and Java Script in your web pages.
There are many good Java mini-programs, known as Java applets, available at
www.gamelan.com and other internet web sites. First, let's try
programming a simple one. Begin by going to www.vivids.com/ij2 for
simple Java programs which accompany an introductory text on using
applets in web pages. Download the java applet, BasicText.class, to
your computer from:
www.vivids.com/ij2/fund/DownLoad/BasicTextDL.html.
Now type the following into a text file and name it java.html, saving it
to the same directory as the BasicText program you just downloaded.
The <applet> tag defines where to find the applet and how to format
it in the web page. The <param> tags are unique to the applet, giving
instructions for controlling the applet.
Now, open java.html with Netscape (this won't work with Web
Explorer because it hasn't been updated to recognize Java). There! You've
used a Java applet in your web page. You can browse Vivids and Gamelan for
other applets and instructions for their use.
Just the Beginning
This will get you started on web programming. Visit the Programming
SIG or read any of the numerous books on web programming to continue
your progress toward web mastery. In the next article, we'll consider
web design considerations and techniques. See you on the net!
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 1997 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG is a trademark of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|