[plt-scheme] servlets utils?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Thu Jan 19 10:36:18 EST 2006

On 1/18/06, Yoav Goldberg <yoav.goldberg at gmail.com> wrote:
> On 1/18/06, Noel Welsh <noelwelsh at yahoo.com> wrote:
> > --- Yoav Goldberg <yoav.goldberg at gmail.com> wrote:
> > > 1/ Are there any available code examples for a "real
> > > life" servlets based web application?

> > None I know of.  Mine are all closed, I'm afraid.

> Can you please give me a url to one of your application? I believe I
> can learn quite a lot on web program organization just by interacting
> with it.. or at least that is the case with traditional apps.

yppdb is available on PLaneT, but I think it requires a currently
broken package. I will be shortly publishing a few other applications
on PLaneT.

> > > 3/ ... I don't understand yet how to
> > > do a more "event-driven" apps, in which I have a page
> > > with many forms/links
> > See send/suspend/dispatch for this.
> Yes, this does sound very promising! Thanks!
> Is there any "official" implementation of it? And does the article
> code works as is for v300? (the urls in the article have the
> continuation id after the filename:
> http://localhost/servlets/y/t4.ss;id323*0*8052612  but in my code it
> appears just after the "servlets" in the path:
> http://localhost/servlets;id323*0*8052612/y/t4.ss ...)

send/suspend/dispatch is always provided via (require (lib
"servlet.ss" "web-server")) in v300.

I don't know about the code in the article, if it still works.

> > > How do I lay out my code for such a thing?

> > It's just good old MVC.

> Well, yeah, but the combination of this MVC with send/suspend is not
> clear to me yet. Who does what? (I know my question doesn't sound very
> clear. Sorry for that.. I just feel rather lost in all of this. Maybe
> some playing with send/suspend/dispatch will give me a better
> perspective on things..)

How does this look to you?

(define other-items (list ...))
(define (page prefs number items)
 (let ([items/limit (list-take number items)])
   (lambda (embed/url)
       (ul ,@(map (make-item->xexpr prefs embed/url)
       (ul (li (a ([href ,(embed/url
                              (lambda _ (page (modify-prefs prefs)
number items)))])
                "Modify Prefs"))
            (li (a ([href ,(embed/url
                              (lambda _ (page prefs (add1 number) items))])
                "More items"))
            (li (a ([href ,(embed/url
                              (lambda _ (page prefs number (swap
other-items items))))])
                "Other list")))))))))

Jay McCarthy <jay at cs.brown.edu>

Posted on the users mailing list.