[plt-scheme] Servlets and diagnosing a blank screen

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Fri Apr 24 14:33:36 EDT 2009

On Fri, Apr 24, 2009 at 12:28 PM, Ben Simon <benjisimon at gmail.com> wrote:
> Howdy,
>
> I was working on some code which produced a bunch of output.  To make it
> easier to read, I decided to generate HTML and look at in the browser. And
> as long as I was generating HTML, I figured what the heck, I should turn my
> code into my very first servlet.
>
> So I hastily through together the following code:
>
> ;; --+--+--
> (define (foo-servlet request)
>   `(html
>     (head
>      (title "Foo App"))
>     (body
>      (form ((method "POST"))
>            (input ((type "text") (name "q")))
>            (input ((type "submit") (value "Go!"))))
>      ,(if (exists-binding? 'q (request-bindings request))
>           (let ([results (do-foo (extract-binding/single 'q
> (request-bindings request)))])
>             `(ul
>               ,@(for/list ([r results])
>                   `(li (a ((href ,(result-url r))) ,(result-value r))))))
>           "-- Enter a Foo arg --"))))
>
> (serve/servlet foo-servlet
>                #:port 8002
>                #:servlet-path "/")
> ;; --+--+--
>
> And holy smokes, it worked!  In no time I was interactively testing `foo'.
> And when foo failed, I got a big 'ol exception stacktrace. Again, all good.
>
> But, for some arguments that I pass to `foo' the browser churns and then
> ends at a blank screen. No exception is thrown, no error message is given.
>
> If I had to wager a guess, I'd say that my call to (do-foo ...) was taking
> to long.
>
> So, my questions are:
>
> 1) Any suggestions for pinpointing an issue where the response is just a
> blank page (with not HTML) returned?

That can happen when you don't return a valid response object in some
contexts, also if you were to return an infinite (because of cycles)
one, or if you went into an infinite loop.

> 2) What's the best way to change the connection timeout?  I've tried
> adjust-timeout! , but that doesn't change anything and I'm not convinced
> it's changing the timeout I want it to change. I see
> adjust-connection-timeout! but I'm not sure how I would use this with
> serve/servlet.

serve/servlet doesn't support a connection timeout like running from
the commandline does, but you can give a different manager argument to
keep continuations longer. If you want to get a longer timeout on the
connections, you'd have to construct a dispatcher like the one in
web-server/web-config-unit, possibly using the helpers that
serve/servlet uses.

Jay

-- 
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay

"The glory of God is Intelligence" - D&C 93


Posted on the users mailing list.