[plt-scheme] Module-based web servlet examples

From: Norman Gray (norman at astro.gla.ac.uk)
Date: Tue Oct 17 06:02:10 EDT 2006

Greetings.

Can anyone point me towards examples of module-based servlets within  
the PLT Scheme web server?

I feel rather foolish asking, because the interface as documented in  
the manual is so simple as to barely need illustration.  But I can't  
get my noddy hello-world servlet to work, I can't find log files  
explaining _why_ it isn't working, and I'm starting to suspect I'm  
misunderstanding something fundamental.

I would have thought that the following would work, based on the  
documentation, and the example in section 9.1 (plus the inclusion of  
the request-structs.ss module):

(module echoing-servlet mzscheme
    (provide interface-version timeout start)
    (require (lib "request-structs.ss" "web-server"))

    (define interface-version 'v1)
    (define timeout +inf.0)

    ; start : request -> response
    (define (start rq)
      `(html
        (head (title "Echo servlet"))
        (body
         (h1 "Echo servlet")
         (table
          (tr (td "method")
              (td ,(request-method rq)))
          (tr (td "uri")
              (td ,(request-uri rq)))
          (tr (td "headers")
              (td ,(request-headers/raw rq)))))))
)

But it simply hangs:

% telnet localhost 8080
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /servlets/echoing-servlet HTTP/1.0

Connection closed by foreign host.
% telnet localhost 8080
Trying ::1...
Connected to localhost.
Escape character is '^]'.
GET /servlets/echoing-servlet HTTP/1.1

^]
telnet> close
Connection closed.
%

It's as if I'm failing to flush something.  I did find one example of  
a module-based servlet at <http://people.cs.uchicago.edu/~jacobm/ 
resume/>, which includes a SEND/FINISH, but wrapping the `(html ...)  
list in one of those didn't magically get me a response.

The servlet log file registers these accesses, but stays schtum about  
what didn't work.

Arghh.  I'm going bald here -- what obvious thing am I missing?


[This is with PLT Scheme 352, using plt-web-server-text, and a web- 
root outside the PLT tree.]

[I also tried using make-response/full, but without success]

[I've grepped around .../collects/web-server/*, and looked through  
dispatchers/dispatch-servlets.ss, but without much illumination, I'm  
afraid]

Thanks for any pointers,

Norman


-- 
------------------------------------------------------------------------ 
----
Norman Gray  /  http://nxg.me.uk
eurovotech.org  /  University of Leicester, UK





Posted on the users mailing list.