[plt-scheme] PLT Web Server

From: Arend P. van der Veen (apvanderveen at att.net)
Date: Tue Jun 29 20:47:56 EDT 2004


I am new to PLT Scheme and have been trying to get some experience with 
the PLT Web Server.  I have successfully installed DrScheme version 207 
for Unix (X11) from source on FreeBSD 4.9.    I have been able to access 
URLs from both localhost and from other hosts in my subnet. 

I am particularly interested in the behavior of the "send/*" functions 
supported by* servlet.ss*.   I initially started experimenting with the 
add example (add.ss) but found that I was leaking memory.  I think that 
this is because there is not any "send/finish" in add.ss.  There is only 
a "send/suspend."  I then decided to try and test the example 
multiplication servlet in section 10.4 (figure 2) in the web server 
documentation (version 207.1).    I created a new file called


and copied the contents of the example into it.  When I access

I get the following error:

Servlet didn't load. 
define: not allowed in an expression context in: (define (answer-page n) 
(quasiquote (html (head (link ((rev "made") (href "mburns at example.com") (...

Does anybody know what the cause of this error is?  Again I am new to 
Scheme so please forgive me if this is a simple error. 

Arend van der Veen

Following is the contents of multiply.ss:

(require (lib "unitsig.ss")
     (lib "servlet-sig.ss" "web-server")
     (lib "servlet-helpers.ss" "web-server"))

(unit/sig ()
  (import servlet^)

  (send/finish (answer-page (* (get-number "first") (get-number "second")))

  ;; answer-page : Number -> Xexpr
  (define (answer-page n)
         (link ((rev "made") (href "mburns at example.com") (title 
       (body (h1 "Answer")
         (p ,(string-append "The answer is " (number->string n))))))

  ;; get-number : String -> Number
  (define (get-number which)
        (get-number-page which))))))

  ;; get-number-page : String -> String -> Xexpr
  (define (get-number-page which)
    (lambda (k-url)
         (link ((rev "made") (href "mburns at example.com") (title 
       (body (h1 "Enter a number")
         (form ((action ,k-url))
           (p ,(string-append "Please enter the " which "number"))
       (input ((type "text") (name "num") (id "num")))
       (input ((type "submit"))))))))))

Posted on the users mailing list.