[racket] Racket web servlets, doctype and planet libraries

From: Markku Rontu (markku.rontu at iki.fi)
Date: Sun Oct 3 08:39:45 EDT 2010

Thanks, my mistake was the lack of that xhtml declaration in the end of the
require and now I understand it goes for the main.rkt in that case.

It would be useful if the documentation search would return something for
"doctype" because I guess many people will want to return conformant
responses from their servlets.

I got the module working after these updates:
- I made all strings byte-strings to comply with the new API. This included
deciding the character set to be utf-8. I suppose this should be
configurable. xhtml-mime-type and make-response/xhtml needed updating.
- I changed response? in the contract to response/full?
- I added xml-declaration to the beginning of the generated response with
the following definition:
  (define xml-declaration
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>")
- I made racket/base the module language.

Maybe these changes should be included in the package as new version?


On Sun, Oct 3, 2010 at 12:43 AM, Robby Findler
<robby at eecs.northwestern.edu>wrote:

> On Sat, Oct 2, 2010 at 4:20 PM, Markku Rontu <markku.rontu at iki.fi> wrote:
> > Hello everybody,
> >
> > I was trying to make some servlets recently and ran into two problems.
> First
> > it was not clear in the documentation how the doctype should be declared
> for
> > random servlets? I didn't want to make a html template based servlet to
> > include the doctype. I'd rather create the main parts of the (x)html
> pages
> > with xexprs in Racket code. What do I need to do?
> >
> > I did find in the Schematics cookbook the dherman/xhtml package that
> seems
> > to do what I want but it doesn't seem to work in Racket. Perhaps the
> library
> > isn't updated to Racket? The error I get after requiring it is:
> >
> "C:\...AppData\Roaming\Racket\planet\300\5.0.1\cache\dherman\xhtml.plt\1\2\main.rkt"
> > (The system cannot find the file specified.; errno=2)
> >
> > Correct report since the directory does not contain main.rkt but only
> > info.ss and xhtml.ss.
> The planet web page [1] suggests this require:
>  (require (planet dherman/xhtml:1:2/xhtml))
> it looks like you tried a different one.
> hth,
> Robby
> [1]:
> http://planet.racket-lang.org/display.ss?package=xhtml.plt&owner=dherman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101003/0e1287bb/attachment.html>

Posted on the users mailing list.