[plt-scheme] Re: Debugging servlets in DrScheme
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 <matthias at ccs.neu.edu> wrote:
>
> On Feb 10, 2007, at 2:20 PM, Alexey Goldin wrote:
>
> > Hmm, I had the same problem in V350.
>
> Yes, I should have written "inclusive".
>
> > Could you please point me what needs to what has to be changed and
> > fixed? I am not in a hurry, I have 2-3 months.
>
> Jay M is working on the server, which is where the changes happened
> that make servlets not work quite right.
>
> > I'd like something like text adventure but on web because kids are
> > having online friends all over the world (via devianart, myspace,
> > etc ). I believe the web game might be attractive --- it is easy to
> > show to others. If you need to install DrScheme to try it out, it is
> > probably much less convenient for their friends to see.
>
> Interesting idea. You would have to run the web server though.
> And we would have to create something like "export servlet to
> server" functionality for the eventual deployment on-line.
>
> > I would like to be able to change code in editor, recompile and see
> > behavior changed immediately without need to copy scripts to other
> > directory, restarting webserver, etc. At least as easy as with
> > Allegroserve.
>
> That's exactly what servlet.ss and servlet2.ss accomplish.
> And that's what I had in mind for my freshmen course.
>
> Your idea makes sense and is superior to my own one-time
> use with freshmen. They didn't get too interested in web
> programming then.
>
> A warning though: it won't look as nice as an AJAX game :-)
>
> Jay?
>
> -- Matthias
>
>
>
>
> >
> > But thanks for pointers, I'll have a look.
> >
> > On Feb 10, 10:15 am, Matthias Felleisen <matth... at ccs.neu.edu> wrote:
> >> Sorry, but the servlet teachpacks haven't worked since v350. This
> >> is mostly my mistake for not maintaining them properly.
> >>
> >> If you are interested in hooking 15 year olds, you may have more
> >> fun doing it via the world.ss teachpacks. We have an experiment
> >> running in MA that gets 10 year olds to write (simple) space invader
> >> games:
> >>
> >> http://www.ccs.neu.edu/home/matthias/HtDP/Extended/index.html
> >> (Prologue for HtDP/2e)
> >>
> >> -- Matthias
> >>
> >
> > _________________________________________________
> > For list-related administrative tasks:
> > http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
--
Jay McCarthy <jay.mccarthy at gmail.com>
http://jay.teammccarthy.org