View Manual - ASNA Developer Network

Transcription

View Manual - ASNA Developer Network
Web for
Smarties
with Caviar
Using Microsoft FrontPage 2002
By Eduardo Ross and
Julie O’Brien
The fast workbook way to learn to
program the Web with Caviar!
Learn the tips and shortcuts for
developing comprehensive applications.
Develop an entire Web application by the
end of the book—in only six easy steps!
Web for
Smarties
with Caviar
Information in this document is subject to change without notice. Names and data used in examples are
fictitious unless otherwise noted.
No component of Web for Smarties with Caviar may be reproduced, disassembled, transmitted,
transcribed, stored in a retrieval system, or translated into any language in any form without the written
permission of ASNA (Amalgamated Software of North America).
Copyright 2002 ASNA - Amalgamated Software of North America. All rights reserved.
Release 4.0
Last Updated, February 2002
i
CONTENTS
Introduction to Web for Smarties .................................................... 1
Getting Started.......................................................................................................2
Using the Tutorial..................................................................................................2
Source Files ....................................................................................................2
Saving Your Work..........................................................................................3
Manual Conventions.......................................................................................4
Step 1 Installing Necessary Web Components ................................. 5
What is a Web Application?..................................................................................6
Web Browsers and Web Servers ....................................................................6
Web Components Needed.....................................................................................7
Tool to Create HTML/ASP Pages.........................................................................7
Microsoft FrontPage 2002..............................................................................8
Personal Web Servers............................................................................................9
PWS for Windows NT Workstation and NT Server ....................................10
IIS for Windows 2000 and Windows XP Professional ................................16
Starting/Stopping Your Web Service (Windows NT and 2000) ..................20
Starting/Stopping Your Web Service (Windows XP Professional)..............21
Registering Acceler8DB for Web Serving ..........................................................23
AVR Licensing....................................................................................................24
Step 2: Creating Static HTML Web Pages ................................... 25
What we will cover in Step 2 ..............................................................................26
Creating HTML Pages for our Web Application ................................................26
Creating a Folder to Hold the Web Application...........................................26
Creating a Home Page (Default.htm) ...........................................................28
Viewing the Home Page...............................................................................33
Adding an Image to the Home Page.............................................................35
Creating another HTML Page (Contactus.htm) ..................................................36
Creating a Hyperlink from the Home Page ..................................................40
Step 2 Summary ..................................................................................................47
Step 3: Creating ASP Pages ............................................................ 48
What we will cover in Step 3 ..............................................................................49
Introduction to Active Server Pages....................................................................49
Creating an ASP Page (Categories).....................................................................50
Linking the Categories Page to the Home Page ...........................................56
Overview of the "Query String" ..........................................................................59
ii
ASNA Visual RPG for Smarties
Creating Another ASP Page (Articles).........................................................60
Linking the Articles Page to the Categories Page ........................................64
Step 3 Summary ..................................................................................................67
Step 4: Creating Caviar Classes ..................................................... 68
ActiveX Controls and Classes.............................................................................69
ActiveX DLL for ASP Pages .......................................................................71
Creating a Library with a Class in AVR/Caviar..................................................72
Creating a Method (ShowCategories) ..........................................................75
Changing the Categories.asp Script..............................................................77
Publishing Database File Records.......................................................................80
Reading the Categories.................................................................................80
Creating a Method (ListArticles)..................................................................83
Creating a Table ...........................................................................................87
Step 4 Summary ..................................................................................................92
Step 5: Creating an HTML Form to Receive Data ....................... 93
HTML Forms ......................................................................................................94
Creating the Order Page (Order.htm) ...........................................................98
Creating the Process Order Page (ProcOrder.asp)......................................108
Creating the Order Class in AVR/Caviar ...................................................109
Step 5 Summary ................................................................................................112
Step 6: ASP Session Object ............................................................113
Application State ...............................................................................................114
Session Object...................................................................................................114
Timeout Property........................................................................................115
Contents Property .......................................................................................116
Appendix A - Glossary of Terms ...................................................119
Appendix B - TroubleShooting Section .........................................125
Index ...............................................................................................127
1
Introduction to Web for
Smarties
This book demonstrates the fundamentals of programming the Web using
ASNA’s Caviar Editor and Microsoft FrontPage 2002 in a “tutorial” format.
The tutorial creates a Product Catalog and Order Entry application that is
developed in progressive steps. Each step in the application represents a step up
in the tutorial’s lessons.
After completing Step 6, you will have a Web application, including features
such as links, input forms, images and more.
At the end of Chapter 6, the application will look like the following:
2
Web for Smarties
Getting Started
This tutorial assumes that you are familiar with AVR/Caviar and have some
prior experience using Web applications.
Using the Tutorial
This tutorial is designed as a “self-learning” tool and includes 6 chapters. Each
chapter is a “step” in which a portion of the application is created. Each step
will build upon the previous step, so it is recommended that you start at Step 1
and progressively work towards Step 6. Each step should take you
approximately an hour. The approximate time to complete each step is included
at the beginning of each chapter.
At the beginning of each chapter, you will find:
•
A summary of the topics that will be covered in that step.
•
The approximate time to complete that step.
•
A visual representation of what the application will look like at the
completion of that step.
At the end of each chapter, you will find:
•
A reference section of each task performed in that step, including how to
perform that task, and the button or shortcut key that is used to perform that
task (if any).
At the end of this tutorial, you will find:
•
Appendix A - A Glossary of Terms to assist you with terms used throughout
this tutorial beginning on page 119.
•
Appendix B - A Troubleshooting section beginning on page 125, which
describes some possible error messages you may encounter while
completing any step of the tutorial.
If you do receive any error, please refer to this section.
Source Files
The completed source files for each of the tutorial steps can be found in the
\Program Files\Asna\LearnWeb40 folder. Web applications are composed of
Web Pages and Caviar Code.
•
The completed Web pages for each step are contained within a folder called
/Web Pages.
•
The completed AVR code for each step is contained within a folder called
Programs NT for Windows NT and within folder /Programs 2K for
Windows 2000 and Windows XP Professional installations.
Introduction
3
Within each of the folders in \LearnWeb40, there is a folder for each step of the
tutorial. The source files for each step are contained in a folder named Stepx,
where x is a number from 1-6, representing the corresponding step of the
tutorial. For instance, you can find Step 4’s completed source files in folder
Step4 within the appropriate folder (Programs 2K or Programs NT), as shown
below.
Even though this tutorial is intended for each step to be done in succession,
you can open the source files of the step prior to the one you wish to
complete. For instance, if you want to do Step 4 – Creating Caviar Classes,
you would open the project in the Step3 folder.
Saving Your Work
When you save your work for a particular step, place it in a folder called Mine
(or whatever you wish) instead of saving it directly onto Stepx.
This way, the original source files do not get overwritten, and you can compare
your application to that of the tutorial.
4
Web for Smarties
Manual Conventions
The following is a list of conventions that are used throughout this tutorial
representing particular functions.
•
A
beside a headline indicates a step-by-step process that you are to
perform.
•
Numbered lists (1, 2, 3, and so on) indicate steps that you should follow.
•
Menu options, buttons, controls and keys that you are to select, along with
words that you are to type will appear in boldface.
•
There are several icons that will appear in the left margin, next to the
instructions. These icons are a visual representation of a task to perform, a
button to select, text to enter, or a web page address to enter, such as shown
below:
Indicates that you are to enter text into a web page, or enter code
into AVR/Caviar.
Indicates a web page to be viewed in the browser.
5
Step 1
Installing Necessary Web
Components
What you will learn in Step 1:
•
The necessary web components needed to create web pages.
•
Where to obtain information on Microsoft FrontPage 2002.
•
Where to obtain and install Personal Web Server (PWS) or Internet Information
Services (IIS).
•
Registering Acceler8DB for Web serving.
•
AVR Licensing.
Approximate Time to Complete Step 1:
Will vary depending upon the components to install, but could take up to an hour.
6
Web for Smarties
What is a Web Application?
A Web application is simply an interactive application that can be accessed through a
corporate intranet or through the Internet. Both the Internet and Intranet are a
network of computers operating on a protocol called TCP/IP, except that any users
outside of your company can access the Internet, and only users within your company
can access your intranet.
Web applications can perform complex business processes on either the client or the
server. In a server-based Web application, the application uses the HTTP Internet
protocol to receive requests from a client, typically a Web browser, process the
associated code, and return the data back to the browser.
The user interface in a Web application can be a series of HTML pages, ASP pages, or
even Caviar objects. Regardless of the type of user interface, the application handles
events, calls methods, and sets and retrieves properties based upon elements in the
HTML or ASP page.
From one perspective, web technology simply provides another arena for your
development efforts. When you deploy Web applications on the Web, you may go
about it differently, by incorporating HTML pages with your Caviar code and so on,
but you're still calling methods, setting properties, and handling events. In this way, all
of your knowledge as a Caviar developer can be easily carried over into the Web
arena.
Web Browsers and Web Servers
The World Wide Web (WWW) is based upon clients and servers.
•
A World Wide Web client is called a Web browser or simply a browser.
•
A World Wide Web server is called a Web server or sometimes just a server.
Web browsers and Web servers use a set of communications rules called Hypertext
Transfer Protocol (HTTP).
The browser sends a request for a web page to the server. The server processes the
request and sends the response back to the browser, where the web browser displays
the contents, as shown in the diagram below.
Step 1
Installing Necessary Web Components
7
The 'page' the browser displays could be an HTML (HyperText Markup Language)
file, an ASP file (Active Server Page), or perhaps a 'file' to download.
HTML is a "language" that allows you to create HTML files (.htm) to display in a
browser. An .htm file is a text document that contains a series of HTML tags that tell
the browser how to display the file. These HTML tags supply information about the
page's structure, appearance, and content.
! See Step 2 for more information on creating and viewing HTML pages.
An ASP file, as its name implies, is a page that is ‘active’ while on the server. That is,
it has some logic or program embedded within it, which will be executed on the
server. ASP's are a mixture of HTML text and script fragments.
! See Step 3 for more information on creating and viewing ASP pages.
Web Components Needed
Before you can begin creating a Web site or application, along with AVR/Caviar, you
must have the following 4 components on your system. This section contains the
components you need on your system, how to verify if you already have them, and
how to install them.
1. A Tool to Create HTML/ASP pages - Microsoft FrontPage 2002
See pages 7 through 9 for more information.
2. A Web Server – PWS (Windows 98/NT) or IIS (Windows 2000/XP).
See pages 9 through 24 for more information.
You must also have the following ASNA Product Licenses registered on your
system using ASNA Registration Assistant. You must contact ASNA to obtain the
Acceler8DB Web Server license. Note that trial versions of AVR do not allow the
creation of DLL’s.
3. Obtain an Acceler8DB Web Server license.
See pages 23 and 24 for more information.
4. Obtain a valid license of AVR (only if you have a trial version).
See page 24 for more information.
Tool to Create HTML/ASP Pages
There are various products available in which you can create and format Web pages in
HTML or ASP.
Note that this tutorial uses Microsoft FrontPage 2002, which is the latest version
of FrontPage. Refer to the following page for more information on Microsoft
FrontPage 2002.
8
Web for Smarties
Microsoft FrontPage 2002
Microsoft FrontPage 2002 is a complete package for Web page authors and Web-site
administrators and contains more features than previous versions of FrontPage.
Microsoft FrontPage 2002 is included with Microsoft Office XP Professional
SPECIAL Edition, Microsoft Office XP DEVELOPER Edition, or it can be
purchased individually.
Microsoft Office XP Professional and Standard versions do not come with
FrontPage 2002. See http://www.microsoft.com/frontpage/howtobuy/default.htm
for a listing of the Microsoft Office XP Packages, and what is included in each.
The tool used to create HTML/ASP pages for this tutorial is Microsoft FrontPage
2002, which is the latest version of Microsoft FrontPage. However, note that there are
older versions of Microsoft FrontPage, such as FrontPage 97, FrontPage 98, and
FrontPage 2000. (The number after FrontPage is the year in which that version was
released).
Please note that there is a Web Smarties tutorial designed specifically for
Microsoft FrontPage 2000, which can be viewed and printed from ASNAs
Product CD, or from the Documentation page on ASNA’s web site.
However, if you have an earlier version of FrontPage, you may want to consider
upgrading. If not, note that the screens, or procedures will vary to what is
shown in this manual. If you have any questions on differences, you would
need to rely on FrontPage’s help file, as the procedures using any other version
will not be included in this manual.
You must already have FrontPage 2002 installed to properly continue with this
tutorial. If you are not sure if you already have FrontPage 2002 installed, follow
the instructions below.
Do I already have Microsoft FrontPage 2002 installed?
To Verify if you already have FrontPage 2002 Installed
1. To verify if you have FrontPage 2002 installed:
•
Select Start - Programs –
Microsoft FrontPage.
! If you found the option above, you already have Microsoft FrontPage
installed on your system. To verify the version of FrontPage, open
Microsoft FrontPage and select Help – About. If it is version 2002,
continue on page 9 – Personal Web Servers.
! If you did not find the above option, any version of Microsoft FrontPage
has not been installed on your system. See the next page for a listing of
prices, options, and links to go to to purchase Microsoft FrontPage 2002.
Step 1
Installing Necessary Web Components
9
Where do I go to get more information on Microsoft
FrontPage 2002?
For more information on Microsoft Office XP Professional and FrontPage 2002, refer
to the following links:
FrontPage Home Page:
http://www.microsoft.com/frontpage/
FrontPage prices and options:
http://www.microsoft.com/office/howtobuy/pricing.htm
FrontPage 2002 Tour:
http://www.microsoft.com/frontpage/evaluation/tour/default.htm
Using FrontPage 2002:
http://www.microsoft.com/frontpage/using/default.htm
Office XP/FrontPage 2002 30-day trial:
http://www.microsoft.com/office/evaluation/trial.htm
How to Articles:
http://search.office.microsoft.com/assistance/product.aspx?p=FrontPage
FrontPage 2002 Books:
http://www1.fatbrain.com/partners/msoffice/frontpage.asp
Tips and Tricks:
http://search.office.microsoft.com/assistance/tips.aspx
Personal Web Servers
The term Web Server is used many times to mean two different things; sometimes it
refers to the actual machine hosting the web site, other times it refers to the program
serving the web pages. You obviously need both a machine and a program.
The Microsoft Personal Web Server includes a Hypertext Transport Protocol
(HTTP) and a File Transfer Protocol (FTP) server. The Microsoft Personal Web
Server (or IIS) is fully integrated into the Windows taskbar and Control Panel, which
allows you to start and stop HTTP and FTP services, to administer the server, or to
change general options.
10
Web for Smarties
For an actual program to serve the pages, you will need to obtain and install one of
Microsoft’s Web Servers. The web server you will need and how you install it
depends upon the operating system of your machine. For example, for Windows
2000/XP Professional operating systems, PWS is called IIS (Internet Information
Services).
Note that you may already have the appropriate Personal Web Server installed on
your system. Refer to the appropriate section (based upon your operating system),
to verify if you already have the appropriate files installed on your system, where
to go to download the necessary files, and the instructions on how to install a
Personal Web Server on your system.
Operating System
Web Server
Windows NT 4.0 Workstation
Personal Web Server 4.0
http://www.microsoft.com/msdownload/ntopti
onpack/askwiz.asp
Windows NT 4.0 Server
See the section below for more information.
Windows 2000 and
Windows XP Professional
IIS Components
All necessary components are automatically
copied to your system when Windows 2000 or
XP Professional was installed (you did not have
to select a special option during installation).
However, you may still need to "Add" the
components.
See page 16 for more information.
PWS for Windows NT Workstation and NT Server
Do I already have Personal Web Server installed?
To Verify if you already have Personal Web Server Installed
1. Check to see if you have any of the following:
•
Select Start - Programs - Windows NT 4.0 Option Pack - Microsoft
Personal Web Server - Personal Web Manager.
•
Open Windows Explorer and check your C: drive for the default web
publishing folder that gets created when PWS is installed:
C:\Inetpub.
•
Search your C:\ drive for the Personal Web Server executable:
PWS.EXE
Step 1
Installing Necessary Web Components
11
! If you found any of the above, you already have PWS installed on your
system. Continue on page 23 to Register Acceler8DB for Web Serving.
! If you did not find any of the above components, you need to download
and install the appropriate PWS. Continue with the instructions below to
download and install PWS.
Where do I go to Download Personal Web Server?
The Setup file for the Personal Web Server for Windows NT Workstation 4.0 and
Windows NT Server 4.0 is available for download on the web.
Follow the instructions below to first download the executable file, then follow the
instructions further on this page to actually install PWS.
To Download Personal Web Server for Windows NT
1. Connect to the appropriate PWS download page at:
http://www.microsoft.com/msdownload/ntoptionpack/askwiz.asp
2. Select Option 1.
3. At the bottom, click on the arrow to the right to select the appropriate Download
option for your operating system, as shown below, then select the Next button.
4. Select the download.exe link at the bottom of the page.
5. You can either Save the program to disk, or Run the program from its current
location. For now, we will save the program to disk. Follow the instructions on
the next page to actually run the download executable and install PWS on your
system.
12
Web for Smarties
How do I Install Personal Web Server?
Now that you have downloaded the setup file (download.exe) to your system as
described in the steps above, you are now ready to actually download and install the
appropriate PWS files.
To Install Personal Web Server
1. Locate and execute the download.exe file on your system.
2. Accept the agreement by selecting Yes.
3. At the Download Options screen, select Install.
4. Select the type of installation your prefer, such as Typical, Minimal or Full
Installation, and select Next>.
5. Select the folder in which to save the files and press Next>. The default is
C:\PWSSetupFiles.
Step 1
Installing Necessary Web Components
13
6. A download location screen will display. Select Next>.
7. Next, the files will be downloaded to your system. A typical installation is 10.6
MB, and the time to download will vary depending upon your internet
connection.
8. After the appropriate files are downloaded, you are now ready to perform the
steps to actually install PWS. The first screen that will display is shown below:
14
Web for Smarties
Note that the title for this screen and the title bars for the subsequent screens
may vary slightly, depending upon which operating system you selected from
the download page, or whether you are installing for Windows 98 or
2000/XP. For example, instead of the title just being Personal Web Server,
it may be titled Windows NT 4.0 Option Pack. However, the screens to
follow should basically be the same.
9. Select the Next> button and the following screen will display.
10. Select the Add/Remove button, then select Next>. The following screen will
display for you to select the Components to be added.
Step 1
Installing Necessary Web Components
15
The typical Options to Select will already be checked, as listed below.
•
Common Program Files
•
FrontPage 98 Server Extensions
•
Microsoft Data Access Components 1.5
•
Personal Web Server
•
Transaction Server
Select all options if you are not sure which options to select.
11. When you are finished selecting your options, select the Next> button, and the
following screen will display.
12. Select the Next> button, and the following screen will display the folder in which
MTS (Microsoft Transaction Server) will get installed.
16
Web for Smarties
13. Select Next>. The appropriate files will now install based upon your selections.
14. When the installation is complete, a screen will display stating "Thank you for
choosing Microsoft Software". Select the Finish button to finish.
15. You will need to restart your system for the settings to take effect.
Congratulations!
Your Personal Web Server components are now properly installed. Continue on
page 23 to Register Acceler8DB for Web Serving.
IIS for Windows 2000 and Windows XP Professional
The Personal Web Server for Windows 2000/XP Professional is called IIS (Internet
Information Services) 5.x. However, to manage the web service for Windows 2000,
the option to access it in Administrative Tools is called Personal Web Manager, as
described on page 20.
IIS 5.x is not installed by default unless Windows 2000/XP Professional is
upgraded over a previous version of Windows that had PWS installed, so you
will probably need to follow the instructions on the next page.
Step 1
Installing Necessary Web Components
17
Do I already have IIS installed?
To Verify if you already have IIS installed
1. To check if you have IIS installed on your system, check the following:
•
Control Panel Select Start Information Services.
Administrative Tools - Internet
! If you found the option above, you already have IIS installed on your
system. Continue on page 23 to Register Acceler8DB for Web
Serving.
! If you did not find the above option, IIS has probably not been
installed, or at least not all of the components. However, the files to
install IIS are already included with the operating system. You only
need to select the Add/Remove Programs option to install the IIS
components, by following the instructions below.
18
Web for Smarties
How do I Install IIS 5.0?
To install IIS 5.0
1. From the Start menu, select Control Panel, then click Add or Remove
Programs. The following screen will display.
2. Select Add/Remove Windows Components (last icon on the left). The
following screen will display.
3. Scroll down just a little, and select the Internet Information Services (IIS)
option, then select the Details… button for a listing of available IIS components,
as shown below.
Step 1
Installing Necessary Web Components
19
4. Accept all the defaults, or select each option, then select the OK button when
done with this screen.
5. Select the Next> button to install the selected IIS components.
Note: If this is the first time that IIS has been installed on this system, you will
prompted to insert the Windows XP Professional CD-ROM into your CD-ROM
drive, as shown below.
On the Welcome screen, select Install optional Windows Components (second
option).
When the components have been successfully installed, the following screen will
display.
20
Web for Smarties
6. Click the Finish button to close the screen.
Starting/Stopping Your Web Service (Windows NT and 2000)
Once you have the proper Personal Web Server (Windows NT) or IIS (Windows
2000) downloaded and installed, you shouldn't need to start the Web Server before it
can be accessed. However, you may want to get familiar with the Personal Web
Manager in case you ever need to start or stop your web service.
Note that the following steps only apply to Windows NT and Windows 2000. For
Windows XP Professional, see Starting/Stopping Your Web Server (Windows XP
Professional) on page 21 . However, you can view and access the same
information, and more, by selecting the Internet Information Services icon within
Administrative Tools.
To Access the Personal Web Manager (For Windows NT and 2000)
1. Select Start – Settings – Control Panel – Administrative Tools - Personal
Web Manager.
The Main page will indicate whether web publishing is on or off. The following
dialog will display.
Step 1
Installing Necessary Web Components
21
2. Click the Start button to make the items on your site available, or when needed,
click the Stop button to temporarily stop the service.
If at any time throughout this tutorial your web page is not accessible, please
perform the steps above to ensure your Personal Web Server is turned On and
indicates your home directory as C:\inetpub\wwwroot. (You may even have to
set up your home directory by selecting Advanced, then adding the folder
location and adding an alias name).
Starting/Stopping Your Web Service (Windows XP Professional)
To Access Internet Information Services (Windows XP Professional)
1. Select Start –Control Panel – Administrative Tools –
Services.
Internet Information
2. The Internet Information Services dialog will display, showing the name of
your computer as the local computer.
22
Web for Smarties
3. Click on the + sign to the left of your computer name, expanding the contents,
then click on the Web Sites folder until you see Default Web Site displaying on
the right, as shown below.
4. You will notice that the State of the default web site is Running. To stop the
web service, select Default Web Site on the right, then select the Stop button
located in the Toolbar, as shown below.
5. The State of the web site will now display Stopped, and the Play button (to the
right of the Stop button) will be enabled. To start the service, select the Play
button, or click on the right-mouse button, and select the Start menu option, as
shown below.
Step 1
Installing Necessary Web Components
23
6. To view or change the properties for the web site, right-mouse click on the
Default Web Site and select the Properties menu option. Multiple tabs will
display. Click on the Home Directory tab to display/change the path and settings
for your default web site. By default, the Default Web Site is pointing to
C:\inetpub\wwwroot.
Please refer to the online documentation within Internet Information Services for
more information.
If at any time throughout this tutorial your web page is not accessible, please
perform the steps above to ensure your web service is Running, and that your
home directory is C:\inetpub\wwwroot.
Registering Acceler8DB for Web Serving
To complete this tutorial, you must obtain an Acceler8DB Web Server license key
from ASNA. Enter the license key using ASNA's registration and licensing tool
called ASNA Registration Assistant.
If you do not obtain an Acceler8DB Web Server license, you will receive an error
as noted on page 82.
Follow the steps on the next page to license the Acceler8DB Web Server.
24
Web for Smarties
To License Acceler8DB for Web Server
1. Contact ASNA to obtain a License Key for Web Serving.
2. Once you are given the License Key, enter the License Key within ASNA
Registration Assistant. Start ASNA Registration Assistant by selecting Start ASNA Product Suite - ASNA Registration Assistant. (You can also select
asnalic.exe from the \Program Files\Common Files\Asna Shared folder).
3. The Registration Assistant dialog will display. You must first select the Product
that you are licensing. Select Acceler8DB Web Server.
4. Enter the License Key that you received from ASNA, along with the other
pertinent information.
5. Select the Register Product button to accept the information, the Exit button to
close Registration Assistant, or the Help button to get help on Registration
Assistant.
AVR Licensing
To complete this tutorial, you must also have a valid license of AVR (which includes
the Acceler8DB engine).
If you have purchased AVR, you will already have the appropriate AVR license
key, and do not need to contact ASNA. If you have a trial version of AVR when
you are ready to go through this tutorial, you will need to call ASNA to obtain a
valid license of AVR to create DLL's. This tutorial involves creating a DLL is
Step 4, and you cannot create a DLL with a trial version.
If you do not obtain a valid AVR license, the "Make DLL" option will not be
available when you Make a DLL for the first time on page76.
Congratulations!
You should have all of your web components installed and you are now ready
to begin creating your web application in the next step.
25
Step 2:
Creating Static HTML
Web Pages
What you will learn in Step 2:
•
How to create HTML pages using Microsoft FrontPage 2002.
•
How to add an image to a page.
•
How to link two web pages together.
Approximate Time to Complete Step 2:
1 hour.
What the Web site will look like after completing Step 2:
26
Web for Smarties
What we will cover in Step 2
Now that you have Microsoft FrontPage 2002 and PWS or IIS installed on your
system, you are now ready to begin creating a web application. Once you have
designed how your application is going to look, the first place to start is to crate
your default “home page” for your application that will reside on your web
server. This home page will contain static HTML containing “links” to other
web pages based on the users’ selection,
In this chapter we are going to create a default home page for our application
(default.htm), as well as create a second html page to link to (contactus.htm)
when text is selected on the default page.
Creating HTML Pages for our Web Application
The first thing we need to do is create a folder in which to contain all of the
files for our web application.
When you installed PWS or IIS on your machine, a folder called Inetpub is
created on your C: drive. Under this folder, the default folders FtpRoot and
WwwRoot are placed.
•
The FtpRoot folder contains the files available to be served via the FTP
(File Transfer Protocol) server.
•
The WwwRoot folder contains the Web pages available to be served via the
HTTP (Hyper-Text Transfer Protocol) server also known as the Web server.
A Web server may have multiple ‘applications’ residing on it (each in a separate
folder). An application is comprised of all the pages within a particular folder
accessible through the server.
Creating a Folder to Hold the Web Application
When creating a folder to hold your web application files, you will want to
create it directly under C:/Inetpub/Wwwroot. For our application, we will
create a folder named NaB, standing for Nuts and Bolts that will contain all of
our application web pages. It is also a good idea to create a folder to hold all of
your images for an application(s), so we will also create an Images folder.
Let’s Create a Folder for our Application
1. Open Windows Explorer and locate and select the C:/Inetpub/wwwroot
folder.
Step 2
Creating Static HTML Web Pages
27
2. To create a new folder, select File – New – Folder. Type in NaB and press
Enter. Refresh your screen by pressing F5. You should now have a new
folder titled NaB, as shown below.
There is an image included in the Images folder in the LearnWeb40 folder
that we will need for our web application. To keep everything together, let's
copy the \Images folder to our Inetput\wwwRoot\NaB folder.
Let's Copy a Folder
1. In Windows Explorer, go to C:\Program Files\ASNA\
LearnWeb40\Images folder.
2. Select and Copy the Images folder (Ctrl+C).
3. Go back to \Inetput\wwwRoot\NaB and do a Paste (Ctrl+V).
28
Web for Smarties
Since you will probably be playing with different applications, we will not place
any files directly within the Wwwroot folder. Instead, we will always restrict
ourselves to placing our files within a particular folder within wwwroot.
Throughout this tutorial, we will always be using the \NaB folder.
Creating a Home Page (Default.htm)
When the browser's request to the server points to a folder instead of to an actual
file name, the server will look for a file called default.htm in that folder. If one
is found, then the server will return it to the browser. This page is considered the
"Home Page". The home page of many web sites is indeed called default.htm.
This allows a user to just point the browser to the server and get back the starting
point of that site.
In the following step, we will create our default home page with the name of
default.htm and place it in the Inetpub\wwwroot\NaB folder.
Step 2
Creating Static HTML Web Pages
29
Let’s Create the Home Page
1. Open FrontPage 2002 by selecting Start –
FrontPage.
Microsoft
2. FrontPage 2002 will come up with a blank page ready to create a new page,
as shown below.
3. Type the following text as the contents of the page:
Note that the last line on the next page appears to be entered as 2lines
due to word-wrap, but is actually just 1 line for you to enter.
Welcome to the Nuts & Bolts web site.
Thru this web site you can contact us.
You can check out our catalog of products as well as placing
orders here.
4. Your screen should now look like the following. (Note that the screen has
been resized, so that only the text that was just entered will display):
30
Web for Smarties
5. Save the file by selecting the Save option from the File menu, or
(Ctrl+S). A dialog similar to the following will display.
“Up One Level” icon, or use the drop down list to
6. First, click on the
locate the C:\Inetpub\wwwroot\Nab folder, as shown below.
Step 2
Creating Static HTML Web Pages
31
7. Next, lets change the Page Title default from “Welcome to the Nuts” to
button
"Welcome to Nuts & Bolts". To do this, select the
located to the right of the Page title: field. The following dialog will
display. )
8. Enter the following title of “Welcome to Nuts & Bolts” as shown below,
and select OK.
9. Next, lets change the default file name of Index.htm to default.htm as
shown below.
32
Web for Smarties
10. Click on the Save button. This page will become our home page.
Note that for the purposes of this tutorial, and to expand the viewing of
our html page, that we will Close the Folder List. This is done by
selecting the X in the upper right corner of the Folder List column, as
shown below.
Step 2
Creating Static HTML Web Pages
33
Viewing the Home Page
Now that we have saved our "home page", we can view the page with our
Internet Browser.
Let's View our First Web Page
1. Launch
page".
Internet Explorer. You will be taken to your default "home
2. Let's go view the default.htm page we just created.
In the Address box of your Internet Browser, enter the following path:
//<the name of your computer>/nab/default.htm and press enter.
For example, the name of my computer is JulieXP, so I would enter:
http://JulieXP/nab/default.htm
If you do not know the name of your computer, you can easily check your
system information by selecting Start – Run – msinfo32 and select OK.
A screen similar to the one below will display. Go down until you see
System Name. That is the name of your computer.
34
Web for Smarties
Note that when the browser’s request to the server points to a folder
instead of an actual file name, the server will automatically look for a
file called default.htm, so you do not have to specify default.htm.
Try entering just the address: //<the name of your computer>/nab. For
example, now I would enter:
http://Juliexp/nab/
Because I will be referring to my computer name (or your computer
name) often, lets use a common name to refer to the computer. TCP/IP
defines the name localhost as the name of the computer where a
command is being made. The address of this localhost is 127.0.0.1. If
your machine was set up with all the defaults, you should already have
such a name defined.
Try using the name localhost in your Internet Browser like this:
http://localhost/nab/
Or even try using the address of localhost:
http://127.0.0.1/nab/
From now on, whenever you see "localhost", you know I am referring to
“your computer”.
Step 2
Creating Static HTML Web Pages
35
Adding an Image to the Home Page
In this next section, we will add an image to our simple HTML page that will
serve as a title and also include a link to a second web page.
1. Go back to FrontPage 2002 to the default.htm file. (If it is not open, you can open
it by selecting File – Recent Files – C:\Inetpub\wwwroot\NaB\default.htm.
2. Place the cursor at the very beginning of the file (in front of "Welcome") and
press Enter to create a blank line.
3. Use your "up" arrow key to place your cursor on the newly-created line, and
select Insert – Picture – From File... The following dialog will display.
4. Select the Browse button to find and select the file
c:\inetpub\wwwroot\nab\images\banner.jpg, as shown below.
36
Web for Smarties
5. Select the Insert button. Your default.htm page should now look like the
following:
6. Save the file by selecting File – Save, or Ctrl+S.
Our home page is taking shape. However, in the next section, we will create
another web page containing the "contact" information that will display
when the word "contact" in the second sentence is selected.
Creating another HTML Page (Contactus.htm)
One of the characteristics that have made the Web so useful is the ability to link
pages together. This enables a user to navigate to a Web site at their
convenience. In the following section, we'll create a second page with the
contact information for our company and place a link from the home page to the
contact page.
Let's Create a Second Web Page (Contactus.htm)
1. In FrontPage 2002, select File – New- Page or Web…. The following
dialog will display.
Step 2
Creating Static HTML Web Pages
2. From the New Page or Web dialog that appears on the right, select Blank
Page within the New sub-category, as shown below.
You will now see the tabs default.htm and new_page_1.htm, as shown
below.
37
38
Web for Smarties
3. Start your page by placing the same banner.jpg image at the beginning of the
page by selecting Insert – Picture – From File – banner.jpg as we did on
page 35.
4. With your cursor directly under the image, enter the following contact
information.
To contact us you can call us at (800) 321-2762 or send us mail at:
100 Main Street
Any Town, USA.
5. Your second html page should now look like the following:
6.
Save the file by selecting the Save option from the File menu, or
(Ctrl+S). The following dialog will display.
Step 2
Creating Static HTML Web Pages
39
7. Select the NaB folder. Lets change the Page Title default from “To
contact us” to "Nuts & Bolts Contacts".
To do this, select the
button located to the right of the
Page title: field. The following dialog will display.
8. Enter the following title of “Nuts & Bolts Contacts” as shown below, and
select OK.
9. Next, lets change the default file name of Index.htm to contactus.htm as
shown below.
10. Select the Save button.
40
Web for Smarties
Congratulations, you have completed your second HTML page that
contains the contact information.
Now we can create a hyperlink from the default.htm page to link to
the Contactus.htm page when the word "contact" is selected.
Creating a Hyperlink from the Home Page
In this section, we will go back to our default.htm page and add a hyperlink to
link the default.htm page to the contactus.htm page.
1. To open the default page, simply select the default.htm tab, as shown
below.
2. Select the word contact from the second sentence of the home page by
double clicking it.
3. Select Hyperlink from the Insert menu (Ctrl+K). The following dialog
will display.
4. Select the NaB folder. The following dialog will display, showing the html
files and their titles.
Step 2
Creating Static HTML Web Pages
5. Select contactus.htm and select OK.
6. Notice now that contact displays as blue text and is underlined, as shown
below.
7. Save the home page by selecting File – Save, or Ctrl+S.
41
42
Web for Smarties
Let's View our Web Page
1. Start Internet Explorer and open the home page by entering
http://localhost/nab.
If your Internet Browser was already showing the page, make sure to
Refresh the window to see your changes by pressing F5.
2. You should see the word contact underlined. Clicking on contact should
display the contactus.htm page in the browser, as shown below.
3. Clicking on contact should display the contactus.htm page in the browser,
as shown below.
Step 2
Creating Static HTML Web Pages
43
4. Click on the Back button of your Internet Browser to take you back to the
home page (default.htm).
Let's View the HTML Source for our Web Page
Now, let’s look at the HTML source file in the browser for the default.htm
page.
1. With the default.htm page displaying in Internet Explorer, select Source
from the View menu.
You will see the elements forming your page. (I have added the indentation
in the following window to make it easier to read).
A well formed HTML document is a heirarchy of elements, marked up by
tags. The <html> tag is the root of the herarchy.
Our page has the following heirarchy:
-
-
<html>
<head>
This section contains the heading of the document
- <meta> Metainformation stating character set as Western Ascii
- <meta> Comment stating the editor used in generating the page
- <title> Title for the browser’s window
<body>
This section contains the body of the document
- <p>
Paragraph with its only content the following picture
- <img> File containg the source for this image and its
dimensions
- <p>
Simple paragraph
- <p>
Paragraph with text and a hyperlink
- <a>
‘anchor’ for the hyperlink stating the page to link to
- <p>
Last paragraph of the page
Whenever you are curious to see the actual HTML source for any file being
displayed by your Web browser, you can right-mouse click on the file, and select
44
Web for Smarties
View Source.
Step 2
Creating Static HTML Web Pages
45
There are many HTML tags, which are beyond the scope of this document.
However, there is a lot of resource material available on creating HTML
pages, and HTML tags on the web. For more information on HTML tags, a
really good site to get started is:
http://www.dtp-aus.com/htmtags1.htm
You can also refer to the "Resources on the Web" book located in your
AVR or Caviar help file for additional resources.
Here is an example of a Web page with more elements:
Image
Table
Paragraph
Form
Hyperlink
Congratulations!
You have just completed creating your default home page for your
application, as well as the creation of a second html page to link to when a
hyperlink text is selected. These pages are "static", in the sense that they
will not change, and are not depended upon user interaction to determine
what information to display.
46
Web for Smarties
In the next step, we will build on our web application by creating 2
additional web pages. These web pages will be an Active Server Page
(ASP), which contains some VB Script which needs to be executed before
displaying the results to the user.
Step 2
Creating Static HTML Web Pages
Step 2 Summary
To
Do This
To create a new folder in
Windows Explorer
In Windows Explorer, select File – New – Folder and enter a folder name.
Open FrontPage 2002
Select Start –
Button/Keys
Microsoft FrontPage.
Save a file
Selecting the Save … option from the File menu.
View the default page
using your computer
name
Open your Internet Browser. Enter the computer
name, folder and html file, such as:
http://Juliexp/nab/default.htm
Use LocalHost as the
computer name and open
the default home page
Open your Internet Browser. Enter ‘localhost’ and
folder, such as: http://localhost/nab/.
Insert an image
Select Insert – Picture – From File menu options,
then select the image to insert.
Create a new web page
Select File - New – Page or Web – Blank Page.
Close a file
Select File – Close.
Open a file
Select the tab of the file to open, select File – Open,
or File – Recent Files and select the page to open.
Ctrl+O
Insert a hyperlink to link
to another web page
Select the word(s) that will contain the link.
Ctrl+K
Ctrl+S
Select Hyperlink from the Insert menu.
Select the .HTM or ASP page of the desired page to
link to.
Refresh the home page
Open your Internet Browser.
Select Refresh from the View menu, or press the F5
button.
Go back to your home
page
Click on the Back button of your Internet Browser.
View the HTML source
for your web page
In the browser, select Source from the View menu,
or click the right-mouse button, then select View
Source.
F5
47
48
Step 3:
Creating ASP Pages
What you will learn in Step 3:
•
The basic mechanics of ASP pages.
•
How to output content under program control.
•
How to obtain the content of a query string.
Approximate Time to Complete Step 3:
1 hour.
What the Web site will look like after completing Step 3:
Step 3
Creating ASP Pages
49
What we will cover in Step 3
Now that we have several static HTML pages created, we are ready to create a
dynamic Active Server Web page, which contains the "script" to call your
Caviar program. After reading the introduction to Active Server Pages, we will
create an Active Server web page with a simple script embedded in it to get
familiar with the mechanics of ASP's.
In this step, we will not have access to the database files yet, so we will be
outputting strings that are constants. Our output won’t seem much different than
if we were creating static pages using just HTML, but keep in mind that the
contents of these strings will be read from database files later on.
The first page we’ll create will display the categories of nuts and bolts that our
company sells. From there, the user would be able to jump to a second page
displaying the articles available for a particular category. The first page will be
the ‘Categories’ page and the second one the ‘Articles’ page.
Introduction to Active Server Pages
When a server receives a request from a browser requesting a particular page, it
will normally read a file from its disk drives and transfer the file untouched.
However, if the extension of the file is .ASP (Active Server Page), then a
different path is taken to produce the ‘file’ to be sent to the browser.
An Active Server Page is, as its name implies, a page that is ‘active’ while on
the server. That is, it has some logic or program embedded within it that will be
executed on the server. ASP's are a mixture of HTML text and script
fragments. If you have ever written or seen RPG programs with embedded
SQL, you can relate to this concept of having a single file contain two entities in
it. In the case of RPG/SQL, part of the program is written in RPG, and some
portion is marked to be SQL. In this latter portion, the syntax and the rules are
not those of RPG any more, but those of SQL. The same kind of process
happens in an ASP. The page typically starts as a normal HTML file with its
tags and text, but then, there is a special tag that marks the beginning of a script
section. These script sections can be sprinkled throughout the HTML body.
When the server receives a request from a browser requesting an ASP page, it
will find and read the file, then it will parse the file looking for the scripts.
Anything that is normal HTML will be sent directly to the browser. Any script,
or code it finds will be executed, and if there is any output generated by that
code, it will be sent to the browser.
The ASP machinery provides several objects, one of which is called Response,
which has a method called Write. The scripts can use this method to generate
output to be sent to the browser. The following is a list of the ASP objects.
•
Request — Receives a request from a user in the browser.
•
Response — Sends information to the browser in order to display it to the
user.
•
Session — Maintains information about the current user session and stores
and retrieves state information.
50
Web for Smarties
•
Application — Manages state that is shared across multiple webclass
instances.
•
Server — Creates other objects and determines server-specific properties
that might influence the webclass's processing.
The scripts can call out to other ‘programs’ to assist in the creation of the
response to be sent to the browser. It is through this mechanism that we will call
into Caviar subroutines, but let us not get ahead of ourselves.
Creating an ASP Page (Categories)
We will create an ASP page in basically the same way that we created an HTML
page using FrontPage. The only difference is that we will include some
VBScript code that will be executed by the server.
The ASP page we’ll create will display the categories of nuts and bolts that our
company sells. From there, the user would be able to jump to a second page
displaying the articles available for a particular category.
Let’s Create the ‘Categories’ Page
1. Using FrontPage, request a normal new page by selecting File – New – Page
or Web – Blank Page. The following will display, as shown below.
A new tab will display called new_page_1.htm You are now ready to
create your web page.
2. You will probably want all of your web pages to look similar, so let's insert
the banner.jpg image again by selecting Insert – Picture – From File –
Banner.jpg, which will give you the following.
Step 3
Creating ASP Pages
51
3. Put your cursor below the image and type in the first line of the file, which
will be the heading.
Nuts and Bolts Categories
5. Next, we'll apply a built-in "style" to the text, which has a predefined font
size and type. To apply a style to your text, do the following:
a) Highlight the line or with the cursor anywhere on the line
b) Click the arrow to the right of the “Style” field, as shown below.
c) Select Heading 2, as shown below.
52
Web for Smarties
d) The text will now have the same font attributes as the style called
Heading 2. The page should now appear like the following:
Entering a Script
Prior to entering our script in code, we need to first tell FrontPage that this page
is a Server ASP page, and that the Server and Client will be using VBScript.
Follow the steps below to enter the desired VBScript.
6. Ensure that you are in Normal view, and select File – Properties. The
General tab will display the following dialog.
Step 3
Creating ASP Pages
53
7. Click on the arrow to the right, and change all three fields in the Designtime control scripting section, as listed below.
Platform:
Server (ASP)
Server:
VBScript
Client:
VBScript
The dialog will now appear as shown below.
8. Next, we will enter the Script for this page directly in HTML code. Select
the HTML tab at the bottom of the page (it is located between the Normal
and Preview tabs, as shown below).
54
Web for Smarties
The following HTML code will display.
Notice in HTML code that the “scripting” options were automatically added
to the code based upon the changes we made to File - Properties in the
previous step.
•
For example, the very first line indicates that the Language is
VBScript.
If you do not see the first line, you can just enter it as follows:
<%@ Language=VBScript %>
•
The other two lines (that are highlighted) indicate the
defaultClientScript is VBScript, and the DTCScriptingPlatform is
Server (ASP).
Step 3
Creating ASP Pages
55
9. Put your cursor on the line after <h2>Nuts and Bolts Categories</h2> and
enter the following script.
<% Response.write ("<p> Bolts")
Response.write ("<p> Nuts")
Response.write ("<p> Screws")
Response.write ("<p> Washers") %>
Note that the open <% and closing %>script tags are used to indicate that
the code is VBScript, and that the text within the opening and closing
script tags will be a different color.
10. Your entire code should now appear as in the following:
Note that you if you select the Normal or Preview tabs, you will not see
any text on the screen.
11. Save the page with the name by selecting File – Save.
•
Change the Page Title: to Nuts & Bolts Categories.
•
Change the File name: to Categories.asp in the NaB folder.
•
Select the Save button on the right.
56
Web for Smarties
We are finished with the ASP page for now, and are now ready to link this
page to our home page, as described in the section below.
Linking the Categories Page to the Home Page
Let's Create a Link to the Categories Page
1. Go to the default.htm page by selecting the default.htm tab, by selecting
File – Open, or by selecting File – Recent Files.
2. Highlight the word catalog in the third sentence.
3. Insert a hyperlink pointing to the Categories page by selecting Insert –
Hyperlink (Ctrl+K).
(Note that you can also right-mouse click on the selected or highlighted
word and select Hyperlink).
The following dialog will display.
4. Double-click on the NaB folder. The contents of the folder will display.
5. Select the categories.asp page and select OK.
Notice now that the word catalog is highlighed in blue and underlined, as
shown below.
Step 3
Creating ASP Pages
57
6. Save the home page by selecting File – Save (Ctrl+S).
Let's View our Categories Web Page
1. Start your Internet Browser and open default.htm.
Note that you can also click the down arrow to the right of the Address
field, which displays the web pages you have visited, with the latest
ones showing first.
(If you had your Internet Browser already showing the home page,
make sure to refresh the window (F5) to see your changes).
2. You should see the word catalog underlined, and clicking it should display
the Categories.asp page in your Internet Browser, as shown below.
58
Web for Smarties
Note: If you do not see the words “Bolts, Nuts, Screws and Washers as
displayed above, please be sure to check the following:
In Default.htm:
•
Ensure that the hyperlink for the word catalog is pointing to
categories.asp located in the \NaB folder. This was covered on page
56. (If you see file://wwwroot/nab/categories.asp, or anything else,
please edit the hyperlink as noted on page 52).
In Categories.asp:
•
Go to the HTML tab and ensure that the VB script is entered
correctly. Check your script as shown in step 9 on page 51
•
Ensure that the Design-time control scripting is set to the Server
(ASP) platform, as described in the Entering a Script section starting
on page 48.
•
Ensure that the page was saved with a file name of "categories.asp"
(as opposed to categories.htm or something else). This was covered
on page 51, step 11.
In Internet Browser:
•
Ensure that you are looking at the page in your Internet Browser, and
NOT the Preview tab within Microsoft FrontPage 2002. (The
Preview tab only allows you to view HTML code, not ASP code).
•
Press F5 to refresh the Default and Categories pages in Internet
Explorer.
Step 3
Creating ASP Pages
59
Let's View our Web Page Source
1. With Categories.asp page displayed in your Internet Browser, select View Source. The html source will display in notepad, as shown below.
Overview of the "Query String"
Now we will create a web page listing the articles for a particular category.
Since we have four categories, we could create one page per category. If we
had four hundred categories, then the task would be completely impractical.
What we’d like to do is create a single page that can handle any category.
When requesting the articles page, a parameter would have to be passed
stating which category the user is interested in. Parameters can be passed to
a page in one of two ways. The first one is by providing a ‘Query String’ as
part of the URL, and the second involves using HTML forms. We will
cover forms in the next chapter in Step 4.
The query string is a list of named values of the general form:
name1=value1,name2=value2,…nameN=valueN
This string is provided to the server by appending it to the address of the
page being requested and separating it with a question mark. In the
following example, the page requested is leaf.htm and the query string has a
couple of values named Fruit and Color with the values of Peach and
Green respectively.
http://server/leaf.htm?Fruit=Peach,Color=Green
The ASP infrastructure provides another object called Request to make the
information sent from the browser available to your application. This
Request object has a property called QueryString containing the named
values of the query string. The QueryString property is of a type called a
collection. Collections are similar to arrays, but with the novelty of having
the array members being accessed via names instead of numbers. A native
array in Caviar uses a numeric index starting at 1 to access the individual
values of the array.
60
Web for Smarties
A collection will use a string index instead of a numeric index. The contents
of the string is the name of the value you want to access.
In the example given above, you would access the Color value with a
statement like this:
MyColor = Request.QueryString(“Color”)
The value of Fruit would be accessible like this:
FruitKind = Request.QueryString(“Fruit”)
It is important to provide the index string spelled exactly (including
case) as the query string states it.
Creating Another ASP Page (Articles)
Now let's create the Articles page, knowing that it will be provided with a query
string. (We will link to it from the Categories page later).
Let’s Create the ‘Articles’ Page
1. Using FrontPage, request a new page by selecting File – New – Page or
Web. Select Blank Page under the New sub-category on the right.
2. Start your page by inserting the picture Banner.jpg by selecting Insert –
Picture – From File – Banner.jpg.
Entering the ASP Script
Prior to entering our script in code, we need to first tell FrontPage that this page
is a Server ASP page, and that the Server and Client will be using VBScript.
Follow the steps below to enter the desired VBScript. (Note that this was also
done on page 48).
3. Ensure that you are in Normal view, and select File – Properties.
4. In the General tab, change the following fields in Design-time control
scripting, so the dialog will now appear as shown below.
Platform:
Server (ASP)
Server:
VBScript
Client:
VBScript
Step 3
Creating ASP Pages
61
5. Next, we will enter the Script for this page directly in HTML code. First,
place your cursor directly below the banner image, then select the HTML
tab at the bottom of the page (it is located between the Normal and Preview
tabs).
Notice in HTML code that the “scripting” options were automatically added to
code based upon the changes we made to File - Properties in the previous step.
6. Notice that the cursor will now be blinking directly after the code for the
banner image and before </body>. At this location, enter the following
ASP script.
<% Response.write ("<h2> Articles for Category ")
Response.write (Request.QueryString("Category"))
Response.write ("</h2>")
Response.write (“<p>”)
Response.write ("<p> Here is the list")
Response.write ("<p> Article 1")
Response.write ("<p> Article 2") %>
As you can see in the script, we are accessing the value “Category” from the
query string, and writing the value back to the browser using the normal
Write method of the Response object. The Tag <h2> marks the beginning
of a heading (type 2) and the tag </h2> marks the end of the heading.
7. The HTML code should now appear like the following.
62
Web for Smarties
Notice that the entire html code for this page is not displayed. To enlarge
the ASP script for your readability, only the code was shown for the
placement and content of the ASP code.
8. Save the page with the name Articles.asp in the NaB folder.
•
Change the Page Title from New Page 1 to Nuts & Bolts Articles and
select the Save button.
We are finished with the articles.asp page for now. Let's view the new
page, then we will create links to this page from the Categories page in the
section below.
Let's View the Articles Page
1. Let's view the articles page using our Internet Browser. However,
since we haven’t created a link to this page, we will have to provide a
category, as shown below:
http://localhost/nab/articles.asp?Category=Nuts
Step 3
Creating ASP Pages
63
Note: If the page did not display due to error(s), or if you do not see the
page as shown above, please be sure to check the following, as well as
Appendix B – Troubleshooting.
In Articles.asp:
•
Go to the HTML tab and ensure that the VB script is entered correctly.
Check your script as shown in step 6 on page 61.
•
Ensure that the Design-time control scripting is set to the Server (ASP)
platform, as described in the Entering a Script section starting on
page60.
•
Ensure that the page was saved with a file name of "articles.asp" (as
opposed to categories.htm or something else). This was covered on
page62, step 8.
In Internet Browser:
•
Check the Internet address you entered to view the Nuts Category in
the articles page as shown on page 62.
•
Ensure that you are looking at the page in your Internet Browser, and
NOT the Preview tab within Microsoft FrontPage 2002. (The Preview
tab only allows you to view HTML code, not ASP code).
•
Press F5 to refresh the Articles page in Internet Explorer.
64
Web for Smarties
Linking the Articles Page to the Categories Page
We are now ready to link the Categories page with the Articles page. If you
recall from the last chapter, you link to pages by providing an HTML tag <a>
called an anchor. FrontPage makes it very easy for us to link pages by selecting
menu options. Doing the links by hand is only a little bit harder.
The anchor tag specifies within the opening and closing tags the word or
sentence to be underlined in the browser for the user to recognize the link.
In an element of the tag; the href element, you provide the URL of the page
to link to. You can include as part of the URL a query string.
The general form for the tag is:
<a href=”page?name=value”> Underlined Words </a>
In the categories page, we will create four links in our script, one per
category. Each link will specify the same page Articles.asp as their target,
but each will specify a different query string.
Let's Create Links in our Categories Page
1. Open the Categories.asp file by clicking on the categories.asp tab.
2. Click on the HTML tab at the bottom to view the HTML code.
3. Locate the 4 lines of ASP script and completely change the script so that
it completely matches the 4 lines of ASP script shown below.
<% Response.write ("<p><a href='Articles.asp?Category=BOL01'> Bolts</a>")
Response.write ("<p><a href='Articles.asp?Category=NUT02'> Nuts</a>")
Response.write ("<p><a href='Articles.asp?Category=SCR03'> Screws</a>")
Response.write ("<p><a href='Articles.asp?Category=WAS04'>
Washers</a>") %>
4. Your HTML code should now look like the following:
5. Save the file (Ctrl+S).
Step 3
Creating ASP Pages
65
Let’s View the Categories Page
1. Start your Internet Browser and go to your default page at
localhost/nab.
2. Select the Catalog link. The Categories.asp page should now look like
the following:
3. Clicking on the Bolts link should take you to the following Articles.asp
page:
66
Web for Smarties
4. Select the Back button and go ahead and try all the links.
You will see how the contents of the Articles.asp page changes
depending upon the link you click from the Categories page to get to it.
It is as if you had four separate pages; one for each category, where in
reality, you have only one. The page is active on the server and the
page changes according to the instructions in your script.
Congratulations!
You have just completed generating 2 Active Server Pages. You should
now have a good start in creating web pages.
Now we are ready to get real information from our database file. For that,
we will have to call into a subroutine or method of a Caviar program. In
the next chapter, we will see how to create our own classes of objects in
Caviar with their own methods.
Step 3
Creating ASP Pages
67
Step 3 Summary
To
Do This
Apply a built-in style
to text
Select a style from the Drop-down style field.
Set the page up to
enable Client and
Server VBScript.
Select File – Properties. In the General tab, change the following fields in
Design-time control scripting.
Enter VBScript
Platform:
Server (ASP)
Server:
VBScript
Client:
VBScript
Select HTML tab and enter an opening <% followed by the code, then end
with a closing %>.
Output text to the
browser
<% Response.write ("<p> Bolts") %>
Use Response.Write, such as:
Request a query
string
<% Response.write (Request.QueryString("Category")) %>
Use Request.QueryString, such as:
68
Step 4:
Creating Caviar Classes
What you will learn in Step 4:
•
What an ActiveX class is.
•
How to use an ActiveX class in Caviar.
•
How to create a class of objects in Caviar.
•
How to create a DLL.
•
How to access ASP objects from within Caviar.
Approximate Time to Complete Step 4:
1 and ½ hours.
What the Web site will look like after completing Step 4:
Step 4
Creating Caviar Classes
69
ActiveX Controls and Classes
As a Caviar programmer, you have been using Active X controls since the
beginning (previously known as OCX's). You are going to draw upon your
experience with ActiveX Controls to understand the use and definition of
ActiveX Classes.
Controls and Classes are very similar. The main difference is that a Control has
a visible portion, mostly used as an element of the user interface, while a Class
doesn’t have a visible element.
The interaction between your program and a Control is done via the Events,
Properties and Methods of the Control. These three concepts apply directly to
the interaction of your program with Classes. Access to the Class’s capabilities
is done via Events, Properties and Methods; also known as the interface of the
Class.
The behavior of a control is defined by the Type of control that it is. The
behavior of an object is defined by the Class of object that it is. This behavior is
defined by the creator of the Class. When you create a Class, you will define not
only the interface to the Class by selecting the names for the Events, Properties
and Methods; but you will also give meaning to each one of these elements.
To instantiate a particular control, you 'draw' it onto a form. To select the
control, you choose one of the bitmaps in the control palette. If you want a
control that is not showing in the palette, you tell the IDE that you want to use it
by adding it to the control palette. Controls are added to the project using the
Custom Control option of the Project menu. This menu brings up a dialog
where you can select a control or a group of controls.
Controls are usually packaged in libraries and delivered via a file with an
extension of OCX. However, they are sometimes delivered in files with an
extension of DLL. What controls to group together and whether to deliver them
in an OCX or a DLL file is made by the company selling the library of controls.
When you select a library of controls in the dialog, all of the controls in that
library are added to the Control Palette. For example, all of the initial controls in
Caviar are contained in the library AVRCTLSLib.
70
Web for Smarties
Classes are also packaged in libraries and delivered in DLL files. ActiveX DLL's
can not be executed, and you can not call a DLL. The only way to access the
DLL is to have methods and properties so a user can get to it. Classes are added
to the project using the References option of the Project menu. This option also
brings a similar dialog enabling the selection of a class library, as shown below.
Once a library has been added to the project, the list of the classes in it and the
interface for each one of them can be seen using the Object Browser, which is
accessible via the View menu in the IDE.
Step 4
Creating Caviar Classes
71
Note that your Object Browser is the means by which you can view the classes
in a library.
You may use more than one instance of a Control type on a form. You
instantiate multiple controls by drawing them on the form. For instance, you
may have two buttons, one called btnOK and the other one btnCancel.
These two objects are two instances of the same Control type, i.e.
CommandButton control. While both objects have the same properties, they
don’t have the same values for them. While the property Caption on one of
them is OK, on the other one it is Cancel. One instance will probably have the
Default property set to True, while the other one will have the Cancel property
set to True. In this scenario, there is one Control type and two instances.
Since Classes do not have a visible element, they can’t be added to the control
palette, nor can they be ‘drawn’ onto forms. To instantiate an object of a
particular class, you write a DCLFLD command in your code, giving the
name of the object and the Class you want to use. There are several ways to
specify a Class. The one normally used is the one stating the name of the library
where the class resides, and the name of the class within the library, separating
both names with a period.
As an example, consider a library to manipulate e-mail. Microsoft ships as part
of its mail client Outlook, a library with classes to manipulate mail items. The
name of the library is Outlook and one of its classes is MailItem. To instantiate
an object of this type, you would code a line like this:
DclFld MyMsg Type(Outlook.MailItem)
The MyMsg field would be used to manipulate mail items. For instance, to save
a mail item you could code:
MyMsg.SaveAs(“myfolder/important”)
ActiveX DLL for ASP Pages
In version 3.1, Caviar introduced a new Project type called ActiveX DLL for
ASP, which presets the following settings of the project to facilitate the
interaction with the ASP machinery.
•
Objects working in an ASP environment require access to two class
libraries, Microsoft Active Server Pages Object Library and COM+
Services Type Library. References to both libraries are automatically
added to the project.
•
The No User Interaction option is selected for the project. This setting
directs the runtime environment to send all runtime errors to a log file
instead of displaying a Message Box as it normally does. All user-coded
MsgBox commands are directed to the same log file. The log file is called
$$AVRERR.TXT and is located in the Program Files/Common
Files/Asna Shared folder. This setting also forbids the use of the Show
command, but not the use of invisible forms.
72
Web for Smarties
•
The Register this component with Component Services on this machine
option is selected. This setting directs the IDE to create a Component
Services package and adds the classes of the project to it. It will automate
the handling of the package every time the library is recompiled.
Enough of concepts, lets create our first library with a class (ActiveX DLL) to
interact with the Web Server’s Active Server Pages.
Creating a Library with a Class in AVR/Caviar
Let’s Create a Library (NutBoltLib)
1. Start AVR/Caviar.
2. Select the File - New menu option.
3. In the New Project dialog, select ActiveX DLL for ASP and click OK.
As mentioned above, selecting this option will automatically pre-set the
Project - Project Setting options of the project to facilitate the interaction
with the ASP machinery. However, we still have to set some names in the
Project Settings dialog.
After selecting ActiveX DLL for ASP, a code window will display with a
name of Class1.VRC as listed below. Notice there is no form, as there is no
visible user interface with UserClasses.
Step 4
Creating Caviar Classes
73
4. Select the Project - Project Settings menu option.
5. In the Project Tab, set the Library Name to NutBoltLib and the Library
Description to Nuts & Bolts Library, as shown below.
Note that the Library Name identifies your component in the Windows
Registry and the Object Browser. It is important that it has a unique name.
The Library name is the name of the type library for your component. The
type library, or TypeLib, contains the description of the objects and
interfaces provided by your component.
It is also used to qualify the names of classes. A combination of library name
and class name is sometimes referred to as a fully qualified class name, or
as a programmatic ID. The fully qualified class name may be required to
correctly identify an object as belonging to your component.
74
Web for Smarties
6. Select the Component tab and enter a Package Name called NutPack and
click OK (as shown in the following dialog.
When creating an ActiveX DLL for ASP page, the Register this component
with Component Services on this machine is automatically selected.
However, since Component Services is comprised of "packages", you must
specify a name for the package.
7. Now we need to set up the properties of the class. In the Properties
Window, set the Description to Product Catalog and the Name to Catalog.
8. Make sure you are using the Caviar Free Format editor by selecting Tools
- Options – Editor Tab from the menu (AVR only).
9. Let's create a folder within the Examples folder to hold our project and call
it NutBolt. To do this in Windows Explorer, select C:\Program
Files\ASNA\Examples. Select File - New - Folder and enter the name
NutBolt.
10. Now save the project to the \NutBolt folder by selecting Save Project from
the File menu. Call the class Catalog.vrc and the project NutBolt.vrm.
Step 4
Creating Caviar Classes
75
At this point, we have a library with a single class in it. The class doesn’t
do anything yet. It has no interface (no events, properties or methods) and
really has no useful behavior. However, it has all the infrastructure
necessary to interact with ASP pages. All we have to do now is define some
methods and implement them.
Creating a Method (ShowCategories)
The next thing we’ll do is to create a method called ShowCategories to write the
list of Categories for our products. In Caviar, you define a method by writing a
public SUBRoutine. This routine will use the Write method of the Response
object. The Response object is provided by the ASP machinery via the object’s
context. To access the object context, we’ll make use of a class - AppServer.
Let’s Create a Method for our Catalog Class
1. Enter the following lines of code in the Catalog class:
DclFld AppServer
Type (COMSVCSLib.AppServer)
DclFld ObjectContext Type (COMSVCSLib.ObjectContext)
DclFld Response
Type (ASPTypeLibrary.Response)
Begsr ListCategories Scope (*Public)
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Response.Write ("<h3>Nuts and Bolts Categories</h3>")
Response.Write ("<p><a href='Articles.asp?Category=")
Response.Write ("BOL01")
//this is the Category ID
Response.Write ("'> ")
Response.Write ("Bolts")
// this is the Description
Response.Write ("</a>")
Endsr
76
Web for Smarties
Please note that when using Windows 2000 or Windows XP Professional,
the MTxAS type library is not used. Windows 2000 and Windows XP
Professional uses the COMSVCSLib type library instead.
The ListCategories routine obtains the proper Response Object, then writes
out a Heading (size 3) with the phrase Nuts and Bolts Categories. It then
writes a single line, using multiple write calls, then creates a link from the
word Bolts that points to the Articles.asp page, just as we did in the previous
step.
2. Now compile your library by selecting Make Project from the File menu.
Note that you should see the following message:
You will receive a warning stating that the ASPTypeLibrary.Response
object is not creatable. The warning is to remind you that you need to
assign the value from the Object Context. It is through the object context
that IIS communicates to your subroutine which Response object is the one
‘connected’ to the user’s browser.
3. Once you got the library to compile cleanly, (with the exception of the
warning stated above) make the DLL by selecting Make NutBolt.dll from
the File menu. Place the DLL in the same folder as the source code
(C:\Program Files\ASNA\Examples\NutBolt).
Note that if the Make NutBolt.dll option is disabled, you do not have a
valid license of AVR. If you have a trial version of AVR, you must
contact ASNA to obtain a valid license to complete this tutorial.
Every time the DLL is compiled, AVR/Caviar’s IDE attempts to ‘Shut
Down’ the COM package to free the previous version of the DLL from any
process using it. Since this is the very first time we compiled the DLL, it
does not exist, nor does the package exist either.
Step 4
Creating Caviar Classes
77
You should now see a message stating the NutBolt.dll successfully created.
If you received any other messages, or the Make DLL was not
successful, please consider checking the following:
- Ensure that you have registered a valid license for the ADB Web
Server.
- Ensure that your code matches the code on page 70, checking
spelling, and ensuring that COMSVCSLIB is used for the AppServer
and ObjectContext type.
After the DLL has been created, the package will automatically be created,
and the Catalog class will be added to the package.
Next, we will go to the Categories.asp page to invoke the ListCategories
method from the ASP script.
Changing the Categories.asp Script
Now we can change the script in our Categories.asp page to instantiate an object
of our Catalog class in our NutBoltLib library and execute the subroutine
ListCategories.
Let’s Change the Categories Script
1. Open the Categories.asp file in FrontPage 2002.
2. Click on the HTML tab and replace the highlighted code shown below with
the code shown in step 3.
78
Web for Smarties
3. Replace the previous code (highlighted) with the code below.
<% Set Catalog=Server.CreateObject ("NutBoltLib.Catalog")
Catalog.ListCategories %>
The first line instantiates an object of our Class, and the second one
executes the subroutine ListCategories.
4. Save the Categories.asp file.
Step 4
Creating Caviar Classes
79
Let’s View our New Categories Page
1. Now we are ready to try our new page. Point your Internet Browser to
your default.htm page (http://localhost/nab).
2. Click on the catalog link. If everything went smoothly, you should get
the following page.
3. Clicking on the Bolts link should take you to the Articles.asp page.
If there was an error, you may check that the spelling of the script in the
ASP is identical to what your library, class and methods are named in
AVR/Caviar. Also refer to Appendix B for some possible error messages
that may occur.
Notice that the web page has two lines saying “Nuts and Bolts
Categories”. The first one comes from the HTML in the ASP, and the
second one comes from the ListCategories method.
4. Let’s delete the Nuts and Bolts Categories heading from the Categories
ASP page. With the Categories.asp page open in the Normal view tab,
highlight the Nuts and Bolts Categories text and select the Delete key.
(The only information you will now see on this page is the banner).
5. Save the Categories.asp page.
80
Web for Smarties
Publishing Database File Records
Our application is going to be using data files kept in the “Asna Local DB”
database. In this database, there is a directory called NutsAndBolts. In it,
there is a physical file named CatByID containing the categories sorted by
ID.
Here is the list of records in the file:
Here is the definition for the file:
Reading the Categories
Let's have the ListCategories method read the categories from the file and
output one line per category with the description marked as a link, and the ID
passed as the value of the query string to the Articles.asp page.
Step 4
Creating Caviar Classes
81
Let's Update the NutBolt Class
1. Open Nutbolt.VRM in AVR/Caviar. The following is the code for the
class. The modifications are shown in bold, blue text:
DclDiskFile CatByID *Input *Indexed +
DbDesc("Asna Local Db")
+
FileDesc("/NutsAndBolts/CatByID")
DclFld AppServer
Type(COMSVCSLib.AppServer)
DclFld ObjectContext Type(COMSVCSLib.ObjectContext)
DclFld Response
Type(ASPTypeLibrary.Response)
BegSr ListCategories Scope(*Public)
DclFld Finished *Ind
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Response.write ("<h3>Nuts and Bolts Categories</h3>")
SetLL CatByID *LoVal
Read CatByID EOF(Finished)
DoWhile *Not Finished
Response.write ("<p><a href='Articles.asp?Category=")
Response.write (CatID)
// this is the Category ID
Response.write ("'> ")
Response.write (CatDesc) // this is the Description
Response.write ("</a>")
Read CatByID EOF(Finished)
EndDo
EndSr
2. After entering the code, make the DLL again.
Let's View the Categories Page
1. Open the Categories.asp page using your Internet Browser.
(If it is already opened, be sure to Refresh your screen to reflect the
new changes by pressing F5).
The updated page should display as shown below.
82
Web for Smarties
Refer to the ASP Troubleshooting below if you encounter any errors
while trying to view the Categories.asp page.
ASP Troubleshooting:
If you do not get the outcome as shown above, check your code and try
again. One error you may encounter is shown below. See the text below for
possible causes for the error and where to go to to find more information
about the error.
This is the information you requested:
Server object error 'ASP 0177 : 8007000e'
Server.CreateObject Failed
/nab/Categories.asp, line 8
Not enough storage is available to complete this operation.
Note that this ASP error is very misleading. The problem actually lies on
the main C-Specs or the implicit open files. If any of these sections of your
code produce an unrecoverable error, ASP will issue the "Not enough
storage..." error.
To find information about the actual problem, look for a file called
$$AVRERR.TXT within the "C:\Program Files\Common Files\Asna
Shared" folder. This file logs the errors that occurred while running DLLs
for ASP.
•
The problem might be that a data file declared in a DclDiskFile is
pointing to a non-existing database name or file name.
•
You may also be missing a proper Web Server license for Acceler8DB.
See Registering Acceler8DB for Web Serving on page 23 for more
information.
Here is a sample of errors that displayed in $$AVRERR.TXT that have
occurred on my machine:
06/20/2000 17:28:32 ERROR: Runtime error occurred in Program SALES
at Line 145:
Class not registered (0x80040154)
06/21/2000 15:24:30 ERROR: Runtime error occurred in Program
CATALOG at Line 2:
Acceler8DB Error: Cannot connect to database server
08/14/2000 10:19:56 ERROR: Runtime error occurred in Program
CUSTOMER at Line 2:
Acceler8DB Error: Invalid or missing ADB multi-tier license
Step 4
Creating Caviar Classes
83
Note that the date, time and the line number in the DLL that caused the
error will display, followed by a more descriptive error that caused the
problem.
Creating a Method (ListArticles)
Now let's provide information about the actual articles in a category by
creating a new method in our class. The new method ListArticles will get
its information from the ArtByCat file.
Here is the definition of the logical file ArtByCat containing the Article
details, which is indexed by the Articles’s Category.
Here are the first few records in the file:
The ListArticles will get the Request object from the Object Context.
From there, it will access the QueryString to obtain the Category being
requested. This Category will be used to read through the ArtByCat file,
listing the information for each article found in the category.
Here is the definition of the subroutine ListArticles. Notice the new
DclDiskFile and the definition and use of the Request object. All the new
code is in bold font.
84
Web for Smarties
Let's Create a Method
1. Open the NutBolt project in AVR/Caviar. The following is the code for
the class.
The modifications are shown in bold, which are all before the
ListCategories subroutine:
DclDiskFile CatByID *Input *Indexed
DbDesc("Asna Local Db")
FileDesc("/NutsAndBolts/CatByID")
DclDiskFile ArtByCat *Input *Indexed
DbDesc("Asna Local Db")
FileDesc("/NutsAndBolts/ArtByCat")
DclFld
DclFld
DclFld
DclFld
AppServer
ObjectContext
Response
Request
Type(COMSVCSLIB.AppServer)
Type(OMSVCSLIB.ObjectContext)
Type(ASPTypeLibrary.Response)
Type(ASPTypeLibrary.Request)
BegSr ListArticles Scope(*Public)
DclFld Finished *Ind
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Request
= ObjectContext["Request"]
ArtCatID
= Request.QueryString["Category"]
Response.write ("<h2> Articles for Category ")
Response.write (ArtCatID)
Response.write ("</h2>")
Chain ArtByCat ArtCatID NotFnd(Finished)
DoWhile *Not Finished
Response.write ("<p>")
Response.write (ArtID)
Response.write ("
")
Response.write (ArtDesc)
Response.write (" sold in ")
Response.write (ArtUnit)
Response.write ("units")
ReadE ArtByCat ArtCatID EOF(Finished)
EndDo
EndSr
BegSr ListCategories Scope(*Public)
DclFld Finished *Ind
. . .
+
+
+
+
Step 4
Creating Caviar Classes
85
2. After entering the new code, make the DLL. When the DLL is created
successfully, you will see the following dialog.
Note however that you may receive the following dialog as well. Just
select the OK button.
Let's Modify Articles.asp to call the ListArticles Subroutine
Now we need to update the Articles.asp page to call the ListArticles subroutine
in our AVR/Caviar application.
1. Open the Articles.asp file.
2. Click on the HTML tab, showing the HTML code.
86
Web for Smarties
3. Let's change the previous script (highlighted text) by entering the
following 2 lines of script and selecting the OK button when finished:
<% Set Catalog=Server.CreateObject ("NutBoltLib.Catalog")
Catalog.ListArticles %>
Note that you will always need only 2 lines of code in your ASP script to call
the AVR/Caviar subroutine in the specified class and library. Your new
HTML code should look like the following: (Please note that to maximize
the size of the dialog, the top portion of the HTML code is not displayed).
4. Select File - Save and save your Articles.asp page.
Let's View the Articles page
1. Now let's view the articles in our web page by opening the
localhost/nab/categories.asp page, then selecting the Socket Products
link. You should now see the following:
Step 4
Creating Caviar Classes
87
If you do not get the results as specified above, first check the ASP
script in your Articles.asp page to ensure all syntax and names are
correct.
If you still do not get the above results, check your AVR/Caviar
class to ensure it is correct.
Note that you can always compare your code and web pages at any
time to the actual source files which are located in \Program
Files\Asna\LearnWeb40. Then select the appropriate folder and
subfolder of the step you are doing.
Creating a Table
The article information on the Articles page would look much better if we
were to deliver it in the form of a table instead of paragraphs.
HTML pages are composed of multiple rows, with the first one being able to
contain the headings. Each row, regardless of being a header row or not, is
composed of data cells. The tags used to make it a table are:
Table Tags
<table> … </table>
<tr>… </tr>
<td>… </td>
<th>… </th>
Marks the whole table
Delimits a table row
Delimits data cells
Specifies the cell as a headings
88
Web for Smarties
The table tag has many optional attributes to control the appearance of the
table. One of the most popular is the border attribute, which specifies the
width of the border lines.
The HTML code for a simple table follows:
<table border=’1’>
<tr>
<th> ID
<th> Description
<th> Units
</tr>
<tr>
<td> DIN0912
<td> Head Cap Screw
<td> KG
</tr>
<tr>
<td> ISO7380
<td> Button Head Cap
<td> KG
</tr>
</table>
</th>
</th>
</th>
</td>
</td>
</td>
</td>
</td>
</td>
The table would look like this:
ID
Description
Unit
DIN0912
Head Cap Screw
KG
ISO7380
Button Head Cap
KG
Let's modify the ListArticles method to produce a table similar to the one
just presented.
Let's Create a Table for our Articles page
1. Open the NutBolt project in AVR/Caviar.
2. Enter the following code for the ListArticles method to produce a table.
Match your code to the code shown below. The code to enter is
shown in bold, and you will also notice that there are some lines you
will remove in the DoWhile Loop.
BegSr ListArticles Scope(*Public)
DclFld Finished *Ind
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Request
= ObjectContext["Request"]
ArtCatID
= Request.QueryString["Category"]
Step 4
Creating Caviar Classes
Response.write ("<h2> Articles for Category ")
Response.write (ArtCatID)
Response.write ("</h2>")
Response.write
Response.write
Response.write
Response.write
Response.write
Response.write
("<table border='1'>")
("<tr>")
(" <th> ID </th>")
(" <th> Description </th>")
(" <th> Unit </th>")
("</tr>")
Chain ArtByCat ArtCatID NotFnd(Finished)
DoWhile *Not Finished
Response.write ("<tr>")
Response.write (" <td>")
Response.write (
ArtID)
Response.write (" </td>")
Response.write (" <td>")
Response.write (
ArtDesc)
Response.write (" </td>")
Response.write (" <td>")
Response.write (
ArtUnit)
Response.write (" </td>")
Response.write ("</tr>")
ReadE ArtByCat ArtCatID EOF(Finished)
EndDo
Response.write ("</table>")
EndSr
3. Make the NutBolt.DLL.
Let's View the Articles Page With a Table
1. Now let's view the Articles.asp page in our Internet Browser. (Be sure to
Refresh the page if it is already opened).
Note that if you just enter http://localhost/nab/articles.asp in your Internet
Browser, you will receive the following page:
89
90
Web for Smarties
This is because a Query String has not been specified. Without a Query String,
the articles.asp page will display an empty table with the column headings ID,
Description, and Unit. Let's enter a query string of Category=NBK01 and press
enter to view the page using a Query String. (see page 59 for a review of the
Query String) The address in your Internet Browser should be:
http://localhost/nab/Articles.asp?Category=NBK01
The new look for the Articles page should display as shown below.
Along with Category NBK01, you can also enter the other categories, such
as:
…/Articles.asp?Category=NBH01
(Headed Bolts)
…/Articles.asp?Category=NBN01
(Hex Nuts)
…/Articles.asp?Category=NBS01
(Screws)
…/Articles.asp?Category=NBW01
(Washers)
Step 4
Creating Caviar Classes
91
Note that you can also access the articles page by opening the default page,
selecting the Catalog link, then select one of the Category links.
Congratulations!
You have just completed step 4 in which you created a DLL, then called
the subroutine in that DLL from an ASP page to display the appropriate
information from your database.
In the next chapter, we will explore how to construct forms in which the
user can enter data.
92
Web for Smarties
Step 4 Summary
To
Do This
Create an ActiveX DLL
for an ASP Page
In AVR/Caviar, select File - New, then select the
ActiveX DLL for ASP option.
Define the name of a
DLL
In AVR/Caviar, select Project - Project Settings Project tab and enter the name for the DLL in the
Project Name field.
Specify a name for the
Component Services
Package
In AVR/Caviar, select Project - Project Settings Component tab and enter a name in the Package
Name field.
Specify a name for the
class within the DLL
In AVR/Caviar, select the Properties window and
enter a name in the Name property.
Create a table
Use the following table tags:
<table> … </table>
<tr>… </tr>
<td>… </td>
<th>… </th>
Button/Keys
Marks the whole table
Delimits a table row
Delimits data cells
Specifies the cell as a headings
93
Step 5:
Creating an HTML Form
to Receive Data
What you will learn in Step 5:
•
What an HTML form is.
•
How to create input elements in a form.
•
How to read the form’s data from a Caviar class.
Approximate Time to Complete Step 5:
1 and ¼ hours.
What the Web site will look like after completing Step 5:
94
Web for Smarties
HTML Forms
HTML provides the tag <form> to define an area of the screen as capable of
accepting input. Within the form section, you can specify input elements of
different kinds to facilitate the entering of data by the user. In this step, we will
create a form to accept orders from the user.
As in the previous sections of the application, there are a lot of
oversimplifications regarding the actual application. The purpose of this book is
to illustrate the Web and Caviar technologies and not how to write business
applications, since you most likely already know how to do that.
The following is an HTML form with all the different types of elements used for
input:
Step 5
Creating HTML Form to Receive Data From the User
95
The form shown above has the following elements:
•
One single line edit box.
•
One multi-line text area.
•
A check box.
•
A group of 3 mutually-exclusive Option Buttons.
•
One drop-down box with possible values of black and white.
•
One list box with three values: Here, There and Everywhere.
•
Two buttons, one to submit the form (to the page that will handle the data
entered by the user) and the other to reset the form elements to its initial
values.
This is the HTML source for the form:
96
Web for Smarties
The form area is delimited by the <form action> and </form> tags. The
opening <form> has two attributes controlling what the browser will do once
the user clicks on the submit button.
•
The first attribute method= is usually set to “POST”, stating that the
information should be ‘posted’ to the Web server. The other possible value
is “GET”. The difference between the two methods is in the way data used
to be passed to CGI programs, a technique now obsolete. You should always
set it to “POST”.
•
The second attribute, action=, specifies which page should get called to
handle the transmitted data. In the preceding case, the HandlerPage.asp
page would get invoked.
The <input> tag is used to define input elements of seven different types. The
attribute type= controls the style of input element.
Attribute type=
Style
Notes
Text
Edit Box
Password
Edit Box
The box displays ‘*’s so that the
characters that have been entered
are not exposed.
Hidden
Invisible string
The browser doesn’t show the
contents of the string. This
element is usually to pass state
information among different areas
of an application. For instance, a
customer’s ID.
Checkbox
Check Box
Radio
Option Button
To group multiple Option Buttons
to make them mutually exclusive,
set the name attribute of all of
them to the same value.
Submit
Button
Submit the form to action handler
when selected.
Reset
Button
Resets the form elements to their
initial values when selected.
The other three input elements, multi-line text area, drop-down box, and list box,
have their own opening and closing tags.
The text area, also known as Text Area, uses the <textarea> tag. The text
between the opening and closing tags is used as the initial value of the text area.
Drop-down boxes and list boxes use the <select> tag to mark a section
composed of multiple <option> tags. To differentiate between a list box and
drop-down box, specify the attribute multiple in the <select> tag.
Step 5
Creating HTML Form to Receive Data From the User
97
Each one of these elements has a name that identifies it uniquely in the form.
This name will be used to access the values entered by the user. The Request
object provides a collection property called Form with all the values entered. If
a particular field is left blank by the user, the collection will not have an element
for that field.
Getting back to our application, the page containing the order form will ask the
user to enter his name, address, and the amount of the article he wishes to buy.
The Orders file has the following format:
FrontPage 2002 makes it very easy to create an input form. The Insert - Form
menu contains a second level menu which has an option for each kind of form
element, as shown below.
98
Web for Smarties
The Order entry form we will create will look like the following:
Creating the Order Page (Order.htm)
Let's Create the Order Page
1. Request a New page in FrontPage 2002 by selecting File – New – Page or
Web – Blank Page (under New sub-category on right).
2.
Insert the Banner.jpg image (Insert – Picture – From File – Banner.jpg)
and press the Insert key to create a new line.
3. Insert a Textbox by choosing it from the Insert - Form menus.
Textbox
When you add the first field of a Form, the form is created at the same
time, which is surrounded with dashed line and contains a Submit and
Reset button, as shown below.
Step 5
Creating HTML Form to Receive Data From the User
99
4. Use the Back arrow key to back up the cursor to right before the textbox,
and type in Product ID:, as shown below.
Notice how the textbox moves to the right as you type. You may want
to leave a few spaces after the colon, and before the textbox.
Also, notice that the Submit and Reset buttons are still located after
the edit box. Click the right-arrow key once, positioning the cursor
directly in front of the Submit button, and press the Enter key 1-2
times to move the buttons down and out of your way.
Note that after entering each element of our form, we will press Enter
to create a new line, thus the Submit and Reset buttons will continue
to move down.
100
Web for Smarties
5. Double-click on the TextBox. The Text Box Properties dialog will display,
as shown below.
6. Change the Name of the text box from T1 to ProdID and the Width in
characters to 7, and click OK, as shown below.
7. Move the cursor to the end of the line and press Enter to generate a new
line.
8. Type in Quantity: (followed by a couple of spaces).
Textbox
a) Insert a new Textbox (Insert - Form – Textbox).
b) Double-click on the text box, setting the following:
!
Name: to Quantity.
!
Width in characters: to 12.
c) Select the OK button.
d) Move the cursor to the end of the line and press Enter.
Step 5
Creating HTML Form to Receive Data From the User
101
9. Type in Your Name: (followed by a couple of spaces).
Textbox
a) Insert a new Textbox.
b) Double-click on the text box, setting the following:
!
Name: to CustName.
!
Width in characters: to 30.
c) Select the OK button.
d) Move the cursor to the end of the line and press Enter.
10. Type in Address: (followed by a couple of spaces).
Text Area
a) Insert a Text Area. (Insert – Form – Text Area)
b) Double-click on the Text Area, setting the following, as shown in the
dialog below.
!
Name: to Address.
!
Width in characters: to 40.
!
Number of lines: to 3.
c) Select the OK button.
d) Move the cursor to the end of the line and press Enter.
11.
Option
Button
Type in Select Delivery Method: FedEx (followed by a space).
a) Insert a Option Button (Insert - Form – Option Button).
b) Double-click on the Option Button and set the following:
! Group name: to Delivery.
! Value: to FEDEX.
! Initial state: Selected (already selected by default).
102
Web for Smarties
c) Select the OK button.
We will put the Ups Option Button on the same line, so do not press Enter
to generate a new line this time.
12.
Option
Button
Type in Ups (followed by a space).
a) Insert another Option Button.
b) Double-click on the Option Button and set the following:
! Group name: Delivery (will already be displayed)
! Value: to UPS.
! Initial state; Not Selected. (When more than one button share the
Group Name, they become mutually exclusive).
c) Select the OK button.
13.
Option
Button
Type in Mail (followed by a space).
a) Insert another Option Button.
b) Double-click on the Option Button and set the following:
! Group name: Delivery (will already be displayed)
! Value: to MAIL.
! Initial state: Not selected (already selected)
Step 5
Creating HTML Form to Receive Data From the User
103
c) Select the OK button.
d) Move the cursor to the end of the line and press Enter.
14.
Type in Rush Processing: (followed by a couple of spaces).
a) Insert a Checkbox (Insert – Form – Checkbox).
Checkbox
b) Double-click on the checkbox and set the following:
!
Name: to Rush.
! Value: ON (will already be displayed).
! Initial State: Not Checked (will already be selected).
c) Select the OK button.
d) Move the cursor to the end of the line and press Enter.
15.
Delete any extra blank lines between the Rush Processing: field and the
Submit and Reset buttons by pressing the Delete key.
16.
With FrontPage 2002, the Submit and Reset buttons are already set to an
appropriate label, as well as the appropriate button types of Submit and Reset,
so you do not need to make any changes to them.
104
Web for Smarties
If you double-click on the
If you double-click on the
button, you will see the following:
button, you will see the following:
17. Now we have to set some properties on the form itself.
a) Place the mouse pointer anywhere within the Form (surrounded with
dashed lines) and press the right-mouse button. A pop-up menu will
display, as shown below.
Step 5
Creating HTML Form to Receive Data From the User
105
b) On the pop-up menu, select the Form Properties… option. The
following dialog will display.
c) Click on the Send to other option (3rd one). Notice that the field
contents are no longer dimmed.
d) Select the
button in the lower left corner of the dialog.
! Action: Enter ProcOrder.asp.
! Method; POST (will already be displayed).
e) Click OK on both dialogs.
106
Web for Smarties
18. Save the page (Ctrl+S) in the \NaB folder.
•
button and change the Page title from
Select the
Product ID to Order Page, and select OK.
•
Change the File name: from Index.htm to Order.htm and select
the Save button.
19. Your completed page should appear like the following:
Congratulations
You have just completed the creation of a form to handle input from
a customer.
Now we need to create a link on the home page to link to the
Order.htm page.
Step 5
Creating HTML Form to Receive Data From the User
107
Let's Create a Link From the Home Page to Order.htm
1. Open the default.htm page.
2. Highlight the words placing orders here and select Insert - Hyperlink to
Order.htm. (Notice that the text is now underlined in blue text).
3. Save the default.htm page.
Let's View the Order Page
1. Open your Internet Browser to view your home page (default.htm) and
click on the placing orders here link.
The following page will display.
2. Enter some information in the input fields and click on the Submit
button.
Since the page that handles the form (ProcOrder.asp) doesn’t exist, you
should get an error on your Internet Browser similar to the following,
indicating that the page could not be found:
108
Web for Smarties
Creating the Process Order Page (ProcOrder.asp)
Now we will create the ProcOrder.asp page and a new class in the
NutBoltLib library to handle orders. The class will be called Order and it
will have at least the method ReceiveNewOne.
Let's Create the Process Order Page (ProcOrder.asp)
1. Go to FrontPage 2002 and create a new page (File – New – Page or
Web - New – Blank Page).
2. Insert the Image banner.jpg.
3. Position your cursor after the image and select the HTML tab at the
bottom of the page.
4. The cursor will be positioned after the image and before the </body>
tag. At this location, insert the following Script.
<% Set Order = Server.CreateObject("NutBoltLib.Order")
Order.ReceiveNewOne %>
Step 5
Creating HTML Form to Receive Data From the User
109
The script calls the ReceiveNewOne method in the Order class within
the NutBoltLib library, even though we have not created the class yet.
5. Save the page as ProcOrder.asp, change the Page title: to Process
Order Class, and select the Save button.
If you were to submit the form (go to default.htm, click on the link
Placing orders here, then click on the Submit button), you would get an
error because we have not created the class yet. The error would look
something like the following (however, it may appear slightly different
depending upon your Operating System and Internet Browser).
Creating the Order Class in AVR/Caviar
Let's Create the Process Order Class in AVR/Caviar
1. Go to AVR/Caviar and open the NutBolt.vrm project.
2. Select the option New Class Module from the Project menu.
3. Go to the Properties window and set the class’s properties as shown
below:
110
Web for Smarties
4. Go to the code window and enter the following code for the Order
class:
DclDiskFile ArtByID *Input *Indexed
DbDesc("Asna Local Db")
FileDesc("/NutsAndBolts/ArtByID")
+
+
DclDiskFile Orders *Update *Indexed
AddRec (*Yes)
DbDesc("Asna Local Db")
FileDesc("/NutsAndBolts/Orders")
+
+
+
DclFld
DclFld
DclFld
DclFld
AppServer
ObjectContext
Response
Request
Type(COMSVCSLIB.AppServer)
Type(COMSVCSLIB.ObjectContext)
Type(ASPTypeLibrary.Response)
Type(ASPTypeLibrary.Request)
BegSr ReceiveNewOne Scope(*Public)
DclFld NotFound *Ind
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Request
= ObjectContext["Request"]
// validate Product ID
ArtID
= Request.Form["ProdID"]
Chain ArtByID ArtID NotFnd(NotFound)
If NotFound
Response.write ("<h2>Invalid Product ID </h2>")
Response.write ("<p>Please click on the back button ")
Response.write ("of your browser and enter a good ")
Response.write ("Product ID </p>")
Return
EndIf
// get the next order number by incrementing last one
SetLL Orders *HiVal
ReadP Orders Eof(NotFound)
If NotFound
OrdID = 1
Else
OrdID = OrdID + 1
EndIf
// Transfer
OrdCustNam
OrdAddr
OrdArtID
OrdArtQ
OrdWay
OrdRush
OrdStatus
Time
values from from to Caviar fields
= Request.Form["CustName"]
= Request.Form["Address"]
= ArtID
= Request.Form["Quantity"]
= Request.Form["Delivery"]
= Request.Form["Rush"]
= "ACEPT"
OrdDate
// place order and response with confirmation
Write
Orders
Response.write ("<p>Order accepted with order ID ")
Response.write (OrdID)
Response.write (".</p><p>Thank you</p>")
EndSr
Step 5
Creating HTML Form to Receive Data From the User
111
4. After entering the code, save the new class with the name of Order.vrc
and Make the NutBolt DLL.
Next, let's view and submit some orders on the Order page.
Let's Try the Order Page
1. Point your Internet Browser to the Order.htm page and enter some data.
(The following lists the contents of the file by using the Acceler8DB File
Editor. Use the contents of the Article ID in the Product ID field).
2. After being successful in entering a new order, you will get a page
confirming your order, as shown below.
Note that the order ID will vary, and will increment every time an order
is submitted.
112
Web for Smarties
If you enter an invalid product ID, you will get the following
message:
As the error states, click on the Back button and re-enter a valid Product
ID as shown on the previous page.
Congratulations!
You have just completed creating a form to accept input from users, as well
as create a class and method to handle the orders.
Step 5 Summary
To
Do This
Insert a Text Box
Select Insert - Form - Textbox.
Insert a Text Area
Select Insert - Form - Text Area.
Insert a Option Button
Select Insert - Form - Option Button.
Insert a Check Box
Select Insert - Form - Checkbox.
Set form properties in an
html page
Press the right-mouse button anywhere over the
form in a web page.
Select the Form Properties option.
Select the Options… button and set Action to the
.asp page to call and set the Method to POST.
Button/Keys
113
Step 6:
ASP Session Object
What you will learn in Step 6:
•
What the ASP Session object is.
Approximate Time to Complete Step 6:
1 and ¼ hours.
What the Web site will look like after completing Step 6:
114
Web for Smarties
Application State
An application's state is the condition in which it is at, at any particular moment.
Traditional programs keep their state in three distinct entities: Variable’s values,
File’s cursors and the Instruction pointer. The programmer is in control of all
three of these entities at all times. The interaction of the user with the state of
the program in traditional programs is very close and the programmer takes it for
granted, because the interaction is implied in his code. With Web applications,
the interaction has to be made explicit.
Interactive users in one tier (host-based) or two tier applications (client/server),
tend to complete the tasks they initiate when running a program. Think of how a
clerk, using a green-screen program, enters the information about the shipment
just received in the warehouse. Consider how a sales associate uses a windows
program to enter the details of the order she just closed over the phone. In both
cases, the user would normally run the program until it has accepted and
validated all the information needed.
On the other hand, consider how users interact with programs on the Web.
Many of them abandon the transaction while in the middle of it. They change
their minds halfway through, or decide to go to lunch or fishing without finishing
the transaction. For this and other reasons, the HTTP protocol is "stateless".
That is, a transaction is comprised by the request made by the browser, and the
response given by the server. This is a very short relationship lasting but a few
seconds. There is no further commitment from the web server but that of
responding with the ‘page’ requested by the browser.
This stateless protocol is indeed needed to achieve the scalability that we have
come to take for granted on modern web sites. Consider how big an AS/400
would have to be to be able to serve hundreds, or even thousands of users
coming into a web site at ‘rush hour’, if each one of them had to have a Job to
serve the application throughout the whole time the transaction took effect.
Working with a stateless protocol makes it hard to maintain any kind of state
directly into a program. By definition, programs are to be stateless also. This is
not good news for traditional programmers. Fortunately for us, the ASP
architecture provides machinery to keep the state outside of our programs in a
fairly easy manner. This is one of the main advantages of using this technology
instead of the aging clumsy CGI methods of building dynamic pages.
Session Object
The ASP architecture groups the sequence of requests from the same browser
and associates them into an object called a Session.
To achieve this, when a user connects for the first time, ASP assigns him a
Session ID, and every transaction from then on has the Session ID associated
with it. The session ID is stored into what is called a ‘cookie’. When the server
sends back the response, the cookie holding the ID is tacked onto the data sent to
the browser. The browser stores the cookie on behalf of the server, and when the
browser sends a new request to the server, the cookie holding the Session ID is
also sent automatically.
Step 6
ASP Session Object
115
Now when this request comes in, ASP will see that it already has a Session ID
assigned to it and will associate this request with the previous one.
As a programmer, you can store your own information into the Session object
and can retrieve it directly from your Caviar code.
Let’s say that we would like to keep a running total of the articles ordered by our
users. The placement of each order would come in as separate request-respond
pair, so we would not really know if this is the second or third time we are into
our Buy method, unless we keep track of it in the Session object.
Timeout Property
Before we go on with our code however, let me explain one more thing about the
Session object. We said that a group of consecutive requests coming in from the
same browser are considered a session. However, if a user comes today to visit
us, and then tomorrow comes again, both visits in most cases would not be
considered part of the saved visit or session, due to the Session Timeout. The
Session Timeout is the amount of time that a user can take between two
consecutive requests and still have both requests be part of the same session. If a
second transaction doesn’t come in before the timeout expires, then the Session
ID is deem terminated, and new requests coming from the users browser would
be grouped under a new Session with its own Session ID.
Twenty minutes is the default timeout. However, you can set a different
period on a session-by-session basis by providing a new value to the property
Timeout of the Session object.
The following shows Caviar’s object browser displaying all of the Properties of
the Session object in the ASPTypeLibrary.
116
Web for Smarties
Contents Property
The Contents property holds user-defined values. It is a collection property,
which is a property that gets indexed by a string instead of a number. To add a
new value to it, all you have to do is decide on a string you will use and use it as
a sub-index to add the values.
With this information on the Session object, let's update our Order class. In our
Order class, we want to keep track of the running total, so let's declare the
Session object and update the ReceiveNewOne method to use the
“RunningTotal” to keep track of this amount.
Let's Update the Order Class in the NutBolt Project
1. Open Nutbolt.VRM in AVR/Caviar and select the Order class.
We’ll have to declare a new variable for the Session and initialize it like the
following. (The modifications to existing code are shown in bold).
. . .
DclFld Request
DclFld Session
Type(ASPTypeLibrary.Request)
Type(ASPTypeLibrary.Session)
BegSr ReceiveNewOne Scope(*Public)
DclFld NotFound *Ind
ObjectContext = AppServer.GetObjectContext()
Response
= ObjectContext["Response"]
Request
= ObjectContext["Request"]
Session
= ObjectContext["Session"]
. . .
2. Next, we’ll compute the total for this order and accumulate it into the
running total. The first time we go through this routine, the Session will not
have a value for “RunningTotal”, so it will return an empty string. That
empty string, when converted to a numeric value, will be zero.
Update the ReceiveNewOne method as follows: (Enter the text in bold
between the last two Response.write statements in ReceiveNewOne
method). Also, notice that the code to enter continues on the next page.
. . .
Response.write ("<p>Order accepted with order ID ")
Response.write (OrdID)
Response.write (".</p>")
// compute total for this order, accumulate in session
DclFld ThisTotal *Zoned Len(9,0)
DclFld RunningTotal *Zoned Len(9,0)
ThisTotal = OrdArtQ * ArtPrice
RunningTotal = Session["RunningTotal"]
RunningTotal = RunningTotal + ThisTotal
Session["RunningTotal"] = RunningTotal
Step 6
Response.write
Response.write
Response.write
Response.write
Response.write
EndSr
3.
ASP Session Object
117
("<p>Your cost for this order $")
(ThisTotal)
(".</p><p>Your total on this session $")
(RunningTotal)
(".</p><p>Thank you</p>")
Make your Nutbolt DLL.
Let's Try the New ProcOrder.asp Page
Let's enter some orders and try out our new code.
1. Open your default page in your Internet Browser and click on the link
placing orders here.
2. Enter the Product ID: DIN0601 with a quantity of 1 and press the Submit
button.
Note: The Product ID is case-sensitive, so you must enter it in all CAPS.
For example, if you enter din0601, you will receive an “Invalid Product
ID” error, as shown on page 112.
When a valid Product ID is entered, the following screen will display.
Again, note that the order ID will vary. Notice that the cost for this order is
$6, as well as the Running Total for this session is $6.
118
Web for Smarties
3. Enter the product DIN0601 again with a quantity of 1 and press the Submit
button.
Note that this time, the cost for the order is still $6, but the cost for the
Session is now $12.
4. Continue to play around with submitting orders, as desired.
Congratulations!
You have just completed updating the ProcOrder page using the Session
Object.
You have also completed the Web for Smarties tutorial at this time.
Keep checking ASNA's web site for updates to this Smarties tutorial,
as well as other Smarties tutorials.
119
A p p e n d i x
A
Glossary of Terms
A
ActiveX
A set of language-independent interoperability technologies that enable software
components written in different languages to work together in networked
environments. The core technology elements of ActiveX are COM and DCOM.
ActiveX components
A unit of executable code, such as an .exe, .dll, or .ocx file, that follows the
ActiveX specification for providing objects. The ActiveX technology allows
programmers to assemble these reusable software components into applications
and services.
ActiveX control
An object that you place on a form to enable or enhance a user's interaction with
an application. ActiveX controls have events and can be incorporated into other
controls. These controls have an .OCX file name extension.
Application
A collection of programs, forms and controls that make up an entire project.
C
Class
A generalized category in object-oriented programming that describes a group of
more specific items called objects. A class provides a template for defining the
behavior of a particular type of object. Objects of a given class are identical to
each other in form and behavior. A class is a descriptive tool used in a program
to define a set of attributes or services that characterize any member (object) of
the class.
Class Module
A module or program containing the definition of a class (its property and
method definitions).
Class Name
The name of a OCX control provided by a third-party vendor. This name is
required on the CLASS parameter in the DCLCTL command.
120
Web for Smarties
Client
A program that facilitates a connection to server computers and manages and
presents information retrieved from those sources. In a client/server
environment, the workstation is usually the client computer. In referring to COM
objects, Client is an object that requests services from another object.
Client/Server
A term generally applied to a software architecture in which processing
functions are segmented into independent collections of services and requestors
on a single machine or segmented among several machines. One or more
processing servers provide a set of services to other clients on the same or across
multiple platforms. A server completely encapsulates its processing and presents
a well-defined interface for clients.
Code Component
An .EXE or .DLL file that provides objects created from one of the classes the
component provides. Formerly OLE server and OLE Automation server.
Code Module
A module containing public code that can be shared among all modules in a
project. A code module is referred to as a standard module in later versions of
Visual RPG.
COM
Component Object Model. The object-oriented programming model that defines
how objects interact within a single application or between applications. In
COM, client software accesses an object through a pointer to an interface, a
related set of functions called methods on the object.
Component
Any software that supports Automation (formerly called OLE Automation),
which means it can be used programmatically in a custom solution. This
includes ActiveX controls (.ocx files), ActiveX documents, and ActiveX code
components.
D
DCOM
Distributed Component Object Model. Additions to the Component Object
Model (COM) that facilitate the transparent distribution of objects over networks
and over the Internet.
DLL
Dynamic Link Library. A set of routines that can be called from procedures and
are loaded in process and linked into your application at run time.
Appendix A
Glossary of Terms
121
DNS
Domain Name Service. A protocol that provides an Internet-wide database of
host and domain names. For example, DNS is used to find the IP address of a
host name written as microsoft.com. Reverse DNS is used to find the host name
given an IP address.
Domain
In Windows NT security, a domain is a collection of computers that are grouped
for viewing and administrative purposes, and that share a common security
database.
E
Executable File
A windows-based application that can be executed outside the environment it
was developed.
F
Firewall
A security mechanism, such as the Microsoft Proxy Server that provides Internet
access from desktops inside an organization, while at the same time preventing
access to the corporate LAN by outside Internet users.
FTP
File Transfer Protocol. A protocol that makes it possible for a user to transfer
files from one location to another over the Internet. URLs of files on FTP servers
begin with ftp://.
H
Host
Any computer that provides services to remote computers or users.
HTML
Hypertext Markup Language. The language in which Web documents are
written. This includes intranet and Internet pages.
HTTP
Hypertext Transfer Protocol. A basic communication protocol for Internet or
Web server file input and output (I/O).
122
Web for Smarties
I
Internet
Abbreviation for Internetwork. A set of dissimilar computer networks joined
together by means of gateways that handle data transfer and the conversion of
messages from the sending network to the protocols used by the receiving
networks. These networks and gateways use the TCP/IP suite of protocols.
Intranet
An Intranet is also a network of computers operating on the TCP/IP protocol, but
it is not global. Generally, intranets are restricted to a particular set of users and
are not accessible by the outside world. For example, many corporations use a
corporate intranet to provide information to their employees, and run another
Internet site for external users. Users within the company can access both the
intranet sites and the Internet, but users outside the company can access only the
company's Internet sites.
IP address
A 32-bit network address that uniquely identifies a system or device on an
intranet or the Internet.
M
MSCS
Systems software from Microsoft that allows you to have multiple servers linked
together in a “cluster” that make the whole group appear as one logical machine.
This means that second or third tier performance and scalability can be improved
by just adding more machines to the cluster. There is no need to bring down the
current server to upgrade it. Also if one machine in the cluster goes down, the
other machine(s) can take over while the problem is being resolved.
MS-DTC
Microsoft Distributed Transaction Coordinator.
MSMQ
Microsoft’s implementation of Data Queues, and contains some very nice
features such as: guaranteed message delivery, COMMIT and ROLBACK of
messages, and message timeout.
MTS
Microsoft Transaction Server. Formerly code-named "Viper," MTS is a new
product that combines the features of a transaction-processing (TP) monitor and
an object-request broker (ORB) in an easy-to-use product.
Multi-tier Architecture
Also known as three-tier, multi-tier is a technique for building applications
generally split into user, business, and data services tiers. These applications are
built of component services that are based on an object model such as ActiveX.
Appendix A
Glossary of Terms
123
O
Object
A combination of code and data that can be treated as a unit, for example, a
control, form, or application component. Each object is defined by a class.
Object Browser
A dialog box in which you can examine the contents of an object library to get
information about the objects provided.
Object Data Type
A data type that represents any Object reference. Object variables are stored as
32-bit (4-byte) addresses that refer to objects.
Object-Oriented Programming
In contrast with procedural programming, involves the use of both objectoriented design and an object-oriented programming language. Instead of
consisting of sets of data loosely coupled to many different procedures, objectoriented programs consist of software modules called objects that encapsulate
both data and processing while hiding their inner complexities from
programmers and hence from other objects.
P
Proxy Server
A proxy server acts as a go-between, converting information from Web servers
into HTML to be delivered to a client computer. It also provides a way to deliver
network services to computers on a secure subnet without those computers
needing to have direct access to the World Wide Web. Thus, secure sites can run
a proxy server on their firewall computer.
Public
Variables declared using SCOPE (*PUBLIC) are visible to all procedures in all
modules in all applications.
S
Scope
The attribute of a variable or procedure that determines which sections of which
modules recognize it. There are three levels of scope: local, global, and public.
Variables that you declare with Public can be accessed by any module, while
variables that you declare in a specific module can be used only within that
module.
Server
A computer running administrative software that controls access to all or part of
a network and its resources.
124
Web for Smarties
T
TCP/IP
Transmission Control Protocol/Internet Protocol. Internet standard for
transferring data among networked computers. TCP monitors and ensures correct
transfer of data. IP receives the data from TCP, breaks it up into packets, and
sends it to a network within the Internet.
U
URL
Uniform Resource Locator. An address that uniquely identifies a World Wide
Web site, usually preceded with http:// such as in this fictitious URL
http://www.example.microsoft.com/. A URL can contain more detail, such as
the name of a page of hypertext, usually identified by a suffix of .html or .htm.
UserControl
A UserControl object is the base object used to create an ActiveX control.
UserClass Control
A UserClass module contains the definition of a class, including its property and
method definitions.
W
World Wide Web
Also the Web or WWW. A set of services that run on top of the Internet
providing a cost-effective way of publishing information, supporting
collaboration and workflow, and delivering business applications to any
connected user in the world. The Web is a collection of Internet host systems
that make these services available on the Internet using the HTTP protocol.
Web-based information is usually delivered in the form of hypertext and
hypermedia using HTML.
WYSIWYG
What You See Is What You Get. Authoring software programs that render a
document on the computer screen the way it will appear in print, even as it is
being edited.
125
A p p e n d i x
B
TroubleShooting Section
The following section contains just a few of the possible errors that you could encounter while going
through this tutorial. Also note that the page number just indicates the main place, or one of the places
this error could occur.
Page No.
Task
Error
Cause
40
Creating a
hyperlink
The page title to create a link to
does not display when you
select Insert - Hyperlink.
When creating a Hyperlink, if
you do not see the Page Title
displayed to link to in the
Open Pages tab, the web
page is currently not opened.
Select File - Open and open
the desired web page, then
go back to the page that will
contain the link and try
again.
72
Calling a method
from an ASP page
Microsoft VBScript runtime
error '800a01b6'
The Catalog has a method
called ListCategories but the
second line in the ASP script
called it ShowCategories.
Object doesn't support this
property or method:
'ListCategories'
73
Calling a method
from an ASP page
Microsoft VBScript runtime
error '800a01a8'
Object required: ''
(Called wrong Caviar method
in ASP script).
The word Catalog is
mispelled as Catalgo in the
second line.
Catalgo.ListCategories
(Mispelled the Caviar class
in ASP script, or it doesn't
exist).
75
Declaring the
Component Services
library in code
Failure to Load Type Library.
Please note that if you are
using Windows 2000 or
Windows XP Professional,
the COMSVCSLib library is
used instead of MtxAS
(Windows NT).
126
Web for Smarties
Page No.
76
Task
Making NutBolt.dll
for the first time
Error
"Make DLL" option from the
File menu in AVR is disabled
Cause
You do not have a valid
AVR license.
If you have a trial version of
AVR, contact ASNA to
receive a valid license key.
79
Viewing the
Categories.asp page
This is the information you
requested:
Server object error 'ASP 0177 :
8007000e'
Server.CreateObject Failed
/nab/Categories.asp, line 8
Not enough storage is available
to complete this operation.
The problem might be that a
data file declared in a
DclDiskFile is pointing to a
non-existing database name
or file name.
You may also be missing a
proper Web Server license
for Acceler8DB. See
Registering Acceler8DB for
Web Serving on page 23 for
more information.
To find information about
the actual problem, look for
a file called
$$AVRERR.TXT within the
"C:\Program Files\Common
Files\Asna Shared" folder.
This file logs the errors that
occurred while running
DLLs for ASP.
81
Accessing the ASNA
Local Database
ORDERS error '80020009'
I/O operation attempted on a file
that is not open
/nab/ProcOrder.asp, line 14
A database file could not
be found. For the details of
the failure, open the log file
$$AVRERR.TXT in the
Program Files/common
Files/Asna Shared folder.
Possible errors are:
Acceler8DB Error: Invalid
Format ID.
117
Calling a method
from an ASP page
Server object error 'ASP 0177 :
800401f3'
Server.CreateObject Failed
/nab/ProcOrder.asp, line 13
Invalid class string
The name of the class was
misspelled or doesn’t exist.
127
Index
$
$$AVRERR.TXT, 71, 82, 126
<
<body>, 43
<head>, 43
<html>, 43
<meta>, 43
<p>, 43, 75, 81, 84
<title>, 43
A
Acceler8DB
licensing for Web Serving, 24
registering for Web Serving, 23
Accessing
Internet Information Services, 21
Action=asp page, 96
Active Server Pages
introduction, 49
ActiveX classes
overview, 69
ActiveX DLL for ASP, 71, 72, 74, 92
Adding images, 35
Address of Localhost, 34
Anchor tag, 43, 64
Application object, 50
Application state
overview, 114
Applying
built-in styles, 51
Articles
asp script, 86
Articles page
creating, 60
creating a table, 88
viewing, 62, 86
Asna Local DB, 80
ASNA Registration Assistant, 23, 24
ASP page
creating, 50
troubleshooting, 82
AVR
activex dll for asp, 71
licensing, 24
AVRCTLSLib, 69
B
Border attribute, 88
Built-in styles
applying, 51
C
Catalog class
code, 75
Categories page, 55, 57, 64, 77, 78, 79, 81
creating, 50
Changing title of page, 31
Classes, 70
Closing a file, 47
Code
order class, 116
process order class, 110
Contactus.htm, 40, 42
Contents property, 116
Cookie, 114
Copying a folder, 27
Creating
articles page, 60
ASP page, 50
categories page, 50
contactus.htm, 36
default html page, 28-29
folder, 26
home page, 28
HTML pages, 26
hyperlink, 40, 64
link, 56
new page, 50
order page, 98
process order page, 108
second web page, 36
table, 87-88
D
Database file records
publishing, 80
DclDiskFile statement, 82
Default html page
creating, 28
viewing, 33, 42, 57, 65, 79, 107, 109
Define the name of a DLL, 92
Downloading
PWS, 11
E
Elements of a form, 95
128
Web for Smarties
F
File
closing, 47
opening, 47
saving, 30
Finding
name of computer, 33
Folders
copying, 27
creating, 26
LearnWeb31, 2
Forms
creating, 94
elements, 95
properties, 105
tags, 96
FTP, 9, 26, 121
FtpRoot, 26
G
Getting started, 2
Glossary of terms, 119
Graphics
adding, 35
H
Home page
adding an imagee, 35
creating, 28
Home Page
viewing, 33
HTML
creating default page, 29
table tags, 87
viewing default page, 33, 42, 57, 59, 65
HTML and Web Authoring, 7
HTML Pages, 7, 26
creating, 26
HTML reference tags, 43
HTML source
viewing, 43
HTMLforms, 94
HTTP, 6, 9, 26, 114, 121, 124
Hyperlink
creating, 40, 56
I
IIS
installing, 18
starting, 21
stopping, 21
verifying if installed, 17
Images
adding, 35
Inetpub folder, 26
Inserting
image, 38
option button, 101
picture, 50
text area, 101
textbox, 98
Installing
Microsoft IIS, 18
Personal Web Server, 12
Personal Web Server for Windows 2000, 16
Instantiate an object, 71, 78
Internet Information Services
accessing, 21
L
LearnWeb35 folder, 2
Licensing
Acceler8DB for Web Serving, 24
AVR, 24
Link
creating, 56
ListArticles, 83, 84, 85, 88
ListArticles method, 83
Listing of
table tags, 87
Localhost, 34, 47, 62
M
Manual conventions, 4
Method=GET, 96
Method=POST, 96
Methods
ListArticles, 83
ReceiveNewOne, 116
Microsoft FrontPage 2002
home page, 9
how to articles, 9
prices and options, 9
tips and tricks, 9
verifying if installed, 8
Msinfo32
finding name of computer, 33
MTxAS type library, 76
N
Name of computer, 34
finding, 33
Index
localhost, 34
New page
creating, 50
Not enough storage is available to complete this
operation., 82, 126
NutBolt Class
code, 81
O
Object Browser, 70
Objects
application, 50
Response, 49
server, 50
session, 49
Write, 49
Opening
a file, 47
Option Button
inserting, 101
Order Class
code, 116
Order Page
view, 107, 111
Overview
activex classes, 69
application state, 114
asp pages, 49
query string, 59
session object, 114
what is a web qpplication, 6
P
Personal Web Servers
installing, 12
starting, 20
stopping, 20
verifying if installed, 10
Picture
inserting, 50
Process order class
code, 110
Process order page
creating, 108
ProcOrder.asp,, 109, 126
Properties
contents, 116
querystring, 59
Publishing database file records, 80
129
Q
Query String
overview, 59
QueryString property, 59
R
Reading the categories, 80
ReceiveNewOne method, 116
Refreshing
web page, 42
Register component with IIS, 72, 74
Registering Acceler8DB for Web Serving, 23
Response object, 49, 61, 67, 75, 76, 81, 84, 88,
110, 116
S
Saving
a file, 30
your work, 3
Script
entering, 52
Server object, 50
Session ID, 114, 115
Session object, 49
overview, 114
Session Timeout, 115
Source files, 2
directory, 2
Specify a name for the MTS/IIS package, 92
Starting
IIS, 21
personal web server, 20
web service, 21
Stateless protocol, 114
Step 1
time to complete, 5
what you will learn, 5
Step 2
summary, 47
time to complete, 25
what it will look like, 25
What we will cover in, 26
what you will learn, 25
Step 3
summary, 67
time to complete, 48
what it will look like, 48
what you will learn, 48
Step 4
summary, 92
time to complete, 68
130
Web for Smarties
what it will look like, 68
what you will learn, 68
Step 5
summary, 112
time to complete, 93
what it will look like, 93
what you will learn, 93
Step 6
time to complete, 113
what it will look like, 113
what you will learn, 113
Stopping
IIS, 21
personal web server, 20
Summary
step 2, 47
step 3, 67
step 4, 92
step 5, 112
T
Tables
creating, 87
tags, 87
Tags
form, 96
table, 87
TCP, 6, 34, 122, 124
Text Area
inserting, 101
TextBox
inserting, 98
Time to complete
step 1, 5
step 2, 25
step 3, 48
step 4, 68
step 5, 93
step 6, 113
Title of page
changing, 31
Troubleshooting
ASP, 82
section, 125
Tutorial
getting started, 2
manual conventions, 4
saving your work, 3
source files, 2
using, 2
Type library, 73
U
URL
Microsoft FrontPage, 8
to download PWS for Windows 95, 11
Using
localhost as the computer name, 47
the tutorial, 2
V
VB Script
entering, 52, 125, 126
Verifying
if Microsoft FrontPage is installed, 8
if IIS is installed, 17
Viewing
articles page, 62, 86
categories page, 81
home page, 33
HTML source, 43
order page, 107, 111
web page, 33, 42, 43, 57, 65
W
Web browsers and web servers, 6
Web components needed, 7
Web page
creating, 36
refreshing, 42
Web server
licensing Acceler8DB, 24
Web service
starting, 21
Well-formed HTML, 43
What is a web application, 6
What it will look like
step 2, 25
step 3, 48
step 4, 68
step 5, 93
step 6, 113
What you will learn
step 1, 5
step 2, 25
step 3, 48
step 4, 68
step 5, 93
step 6, 113
Windows 2000
Installing Personal Web Server, 16
Write object, 49
WwwRoot, 26
131