[plt-scheme] send/suspend/dispatch and javascript?
Bob McCormick wrote:
> If anyone can tell me what I'm doing wrong I'd appreciate it. I'm
> very new to Scheme. I was going to re-writing some CGI's I've done
> previously in Perl as an exercise to learn Scheme, but maybe I've
> bitten off more than I can chew. :-)
You're pretty close, so don't give up just yet. The immediate problem can
be fixed by moving the definitions of url-append/path and
send/suspend/dispatch to after the "(unit/sig () (import servlet^)" line -
that'll fix the dependency issue, although I'm not saying it's the best
solution, just expedient. (send/suspend/dispatch is defined as part of the
servlet^ interface, so that's why that works.)
After that, you'll run into some other problems. Since I take it this isn't
homework, and since send/suspend/dispatch really ought to be a drop-in
library routine, I've provided fixes for the other remaining issues below.
If you want to work it out for yourself, don't read any further. ;)
If there are any you don't understand, please ask.
1. Change the definition of send/suspend/dispatch to eliminate the
contract, because that seems broken - I didn't investigate why. The revised
definition begins with the following two lines:
(define send/suspend/dispatch
(lambda (page-func)
2. In your require clause at the top, you'll need to specify these as well:
(lib "url.ss" "net")
(lib "list.ss")
(lib "string.ss")
(You would have found this out once the earlier problems were fixed)
3. Fix typo: s-rul
4. Add omitted (url-host url) as second argument to make-url in
url-append/path (check the paper).
5. Fix your calls to page2 and page3 to pass the request parameter, which
those functions expect. For extra credit, you can abbreviate expressions of
the form "(lambda (x) (f x))" to just plain "f" (without the quotes); if you
don't know what I mean, ignore it for now.
6. page3 doesn't return a valid x-expr, so you'll get an error on that page
until you fix it.
Anton