95.205C/D
Internet Applications
Assignment 2
|
This assignment is due on Friday, March 2, 2001, at 2:00
pm
|
Instructions
These are the instructions for completing assignment 2:
-
Late assignments will NOT be marked.
-
This assignment is to be done in Perl and CGI.
-
The scripts must be installed on your course account for 95.205.
Otherwise, your assignment will not be marked.
-
It is NOT mandatory that you do Part 1 of the assignment. However, completing
Part 1 may help you understand the assignment better and may help you to
plan your solution to Part 2. Part 2 of the assignment MUST be done.
-
Marks will be awarded for Part 2 of the assignment only.
Print a copy of the answer sheet and use
it to hand in your answers to this assignment.
Part 1
In this part you will create three CGI scripts:
-
Shop205Home.cgi
-
Shop205DisplayCategories.cgi
-
Shop205Order.cgi
Please adhere to those names in your solution.
Note: You don't have to implement a home page in HTML. It should
be generated by the CGI script.
Shop205Home.cgi
When the user selects the flower image in the web page created for assignment
1, the associated link requests the Shop205Home.cgi script. This script
sends the following web page to the user:
When the user clicks the submit button labeled "Show Selected Categories",
the Shop205DisplayCategories.cgi script is called.
Shop205DisplayCategories.cgi
The Shop205DisplayCategories.cgi script dynamically creates a web page
that displays the items available in the selected categories. For example,
if the user selected "Roses" and "Orchids", the following web page would
be created and sent to the user:
Shop205Order.cgi
The Shop205Order.cgi script is called when the user clicks on the button
labeled "Place Order" in the page displayed by the Shop205DisplayCategories.cgi
script. The Shop205Order.cgi script then dynamically creates a web page
that thanks the user for their order, lists the items to be ordered (including
the type, description, and price of each item), and states the total cost
of order (including 7% GST and 8% PST).
Note: At this point we won't store the order on the server. You
will be asked to do this in the next assignment.
Part 2
A common complaint about CGI programming is the mixing of program code
(in our case Perl) with HTML. Templates allow for the separation of program
code from HTML. In this part of the assignment, you will create and use
HTML templates so that the HTML and Perl program code can be separated
in your scripts. The HTML templates can also be "re-used" with different
data.
Suppose that just after you completed Part 1 of the assignment, you
were asked to build a similar site for an online CD vendor. Had you used
templates to build the the first application (for the online flower vendor),
the work necessary to build the second site would have been marginal.
HTML::TEMPLATE
Download the HTML::Template
module and install it on your course account.
Documentation
is also available.
Shop205Home.cgi Revisited
A template is now used to provide the structure of the web page, and the
script provides values for the following variables:
-
name of the store to be displayed in the heading, e.g. "CD205"
-
type of product to be displayed in the text "Please indicate the type of
...", e.g., "CDs"
-
category names, e.g., "Flowers for Easter", "Roses", "Orchids", etc.
The objective is to use these variables as parameters to TMPL_VAR and TMPL_LOOP
tags.
Shop205DisplayCategories.cgi Revisited
A template is now used to provide the structure of the web page, and
the script provides values for the following variables:
-
table heading to indicate the product code, e.g. "Type" or "ISBN"
-
table heading to indicate the product description, e.g. "Arrangement" or
"Title"
-
information about each product (product code, description, price, and whether
it is already in the shopping cart or not; we will need this last one for
the next assignment)
Shop205Order.cgi Revisited
A template is used to provide the structure of the web page, and the
script provides values for the following variables:
-
information about the ordered items (product code, description, and price)
-
GST and PST
-
total cost of the order