Complete this assignment with the same team you worked with for Substitution (Written). You and your partner must each understand the answers to all the problems, so don't just split up the work.

Assignment Task

  1. Repeat the Raw Web Programming assignment using the PLT Scheme Web Server.
  2. Compare and contrast your raw web program with your Scheme web program (see below).

Writing your Servlets

Your servlets must be written in the Web Application language level. Consult the PLAI manual for more information on the interface provided by the Web Application language and the functions you must define to write a servlet.

Restrictions

You should not be using hidden fields for this assignment. All your state should be stored in continuations server-side. See below for an example.

Example

This program calculates the sum of two numbers. Run it to see how it works.
(define (make-number-page msg)
   (lambda (k-url)
     `(html
       (body
        (form ((action ,k-url) (method "post"))
              (h2 ,msg)
              (input ((type "text") (name "num")))
              (input ((type "submit") (name "submit") (value "Submit"))))))))

(define (make-result-page x)
  (lambda (k-url)
    `(html
      (body
       "Result: "
       ,(number->string x)))))

(define (send-and-get msg)
  (local ((define req (send/suspend (make-number-page msg)))
          (define bindings (request-bindings req)))
          (string->number (extract-binding/single 'num bindings))))

(define (start req)
  (local ((define num1 (send-and-get "first number"))
          (define num2 (send-and-get "second number")))
    (send/suspend (make-result-page (+ num1 num2)))))

Quasiquoting

In Scheme, it's possible to begin a quoted list with ` instead of '. This is called quasiquoting, as opposed to quoting. Quasiquoting lets you evaluate specific elements of a quasiquoted expression instead of directly returning the expression. To force evaluation of an element in a quasiquoted expression, prefix the element with a comma. For example, to generate the list '(1 2 3 4) you may write `(1 2 ,(+ 0 3) 4). Quasiquoting is a convenient way to insert dynamic elements into HTML templates. If you want more information or examples, the PLT Scheme guide and the Scheme standard are good places to look.

Handin

Turn in a file, servlet.ss, containing your program. In addition, if your servlet references any static files (such as images), turn them in as well.

Also, include a readme file in your submission. In it, list the names of the people in your group. Additionally, contrast 3-5 language features that you used in this assignment to the language features encountered in the raw web programming assignment. The analysis should be 2 paragraphs or fewer. Grammar and word choice matter.