[racket] Can't find how to use stateless servlets.

From: Rahul Kumar (rahulsinner at gmail.com)
Date: Sat May 7 21:42:14 EDT 2011

Thanks Jay.

Worked like a charm. For anyone else fighting with the same issue, the only
change needed is the `#lang web-server` in-place of `#lang racket` in the
code sample - `#:stateless? #t` is already there.

Out of curiosity, since I didn't need to make any code changes to make
stateless work, is there any reason to run stateful servlets? The only
concern I see is the default stuffer which does disk writes - that too if
the urls are large. Nothing a fast disk and short ulrs can't mitigate.



On Sun, May 8, 2011 at 6:57 AM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:

> Stateless servlets must be written in the #lang web-server language.
>
> Once you write them that way, if you want to start a server that
> launches them, you need to use #:stateless?
>
> Unless you have both pieces, it won't work.
>
> Jay
>
> 2011/5/7 Rahul Kumar <rahulsinner at gmail.com>:
> > Hi,
> > What do I need to do to run a stateless servlet?
> > Consider the following example taken from the web tutorial. I just added
> > `#:stateless? #t` while starting.
> > #lang racket
> > (require web-server/servlet
> >          web-server/servlet-env)
> > ; start: request -> response
> > (define (start request)
> >   (show-counter 0 request))
> > ; show-counter: number request -> doesn't
> > ; Displays a number that's hyperlinked: when the link is pressed,
> > ; returns a new page with the incremented number.
> > (define (show-counter n request)
> >   (send/suspend/dispatch
> >     (lambda (url)
> >       (response/xexpr
> >         `(html (head (title "Counting example"))
> >                (body
> >                  (a
> >                    ([href ,(url
> >                              (lambda (req)
> >                                (show-counter (add1 n) req)))])
> >                    ,(number->string n))))))))
> > (serve/servlet start
> >                 #:port 7070
> >                 #:servlet-path "/"
> >                 #:listen-ip #f
> >                 #:stateless? #t)
> >
> > This doesn't work. I am looking at the web server reference but I can't
> find
> > a proper example.
> >
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://lists.racket-lang.org/listinfo/users
> >
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://faculty.cs.byu.edu/~jay
>
> "The glory of God is Intelligence" - D&C 93
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110508/7e181968/attachment.html>

Posted on the users mailing list.