[plt-scheme] Re: Debugging servlets in DrScheme
Just what the doctor ordered!
Thanks a lot! I'll try to work my way from here. Works in 360, does
not work in 352 and before.
On Feb 12, 2:01 pm, "Jay McCarthy" <jay.mccar... at gmail.com> wrote:
> One thing you can do to run the web-server from within DrScheme is to
> use the (lib "servlet-env.ss" "web-server" "tools") library. Here's an
> example:
>
> (module servlet-env-test mzscheme
> (require (lib "servlet-env.ss" "web-server" "tools"))
>
> ; request-number : str -> num
> (define (request-number which-number)
> (string->number
> (extract-binding/single
> 'number
> (request-bindings (send/suspend (build-request-page which-number))))))
>
> ; build-request-page : str -> str -> response
> (define (build-request-page which-number)
> (lambda (k-url)
> `(html (head (title "Enter a Number to Add"))
> (body ([bgcolor "white"])
> (form ([action ,k-url] [method "post"])
> "Enter the " ,which-number " number to add: "
> (input ([type "text"] [name "number"] [value ""]))
> (input ([type "submit"] [name "enter"] [value
> "Enter"])))))))
> #;(on-web
> `(html (head (title "Sum"))
> (body ([bgcolor "white"])
> (p "The sum is "
> ,(number->string (+ (request-number "first")
> (request-number "second")))))))
>
> (on-web (+ (request-number "first") (request-number "second"))))
>
> When you use the `on-web' function, a temporary server is run from
> DrScheme on port 8080 and a browser window is opened to a temporary
> servlet. This should help you test servlets from DrS.
>
> Jay
>
> On 2/10/07, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
>
>
>