Internet and Web Resources

Answers to Self Review Exercises

19.1

a) get and post. b) cache. c) middle. d) machine name. e) XHTML. f) QUERY_STRING. g) form.

19.2

a) True. b) True. c) False. The middle tier implements business logic to control interactions between application clients and application data. d) False. A dynamic Web page is a Web page that is created programmatically. e) False. The pairs are joined with an ampersand (&). f) False. XHTML documents are more efficient than CGI scripts, because they do not need to be executed on the server side before they are output to the client. g) True.

Exercises

19.3

Define the following terms:

  1. HTTP.
  2. Multitier application.
  3. Request method.

19.4

Explain the difference between the get request type and the post request type. When is it ideal to use the post request type?

19.5

Write a CGI script that prints the squares of the integers from 1 to 10 on separate lines.

19.6

Write a CGI script that receives as input three numbers from the client and displays a statement indicating whether the three numbers could represent an equilateral triangle (all three sides are the same length), an isosceles triangle (two sides are the same length) or a right triangle (the square of one side is equal to the sum of the squares of the other two sides).

19.7

Write a soothsayer script that allows the user to submit a question. When the question is submitted, the script should choose a random response from a list of answers (such as "It could be", "Probably not", "Definitely", "Not looking too good" and "Yes") and display the answer to the client.

19.8

Modify the program of Figs. 19.1319.14 to incorporate the opening XHTML form and the processing of the data into a single CGI script (i.e., combine the XHTML of Fig. 19.13 into the CGI script of Fig. 19.14). When the CGI script is requested initially, the form should be displayed. When the form is submitted, the CGI script should display the result.

19.9

Modify the viewcart.cgi script (Fig. 19.23) to enable users to remove some items from the shopping cart.

Категории