[racket] How does the web server find servlets?
On Thu, Sep 1, 2011 at 3:35 PM, Doug Orleans <dougorleans at gmail.com> wrote:
> I wanted to know how the Racket web server figures out whether a URL refers
> to a servlet or not. In particular, I was curious about how the
> "servlet-root" path in the configuration table was used (its default is
> "."). The closest thing I could find to documentation was this bullet point
> in the docs for "web-server@":
> Execute servlets in the mapping URLs to the given servlet root directory
> under htdocs.
> I've read this sentence many times and I still can't parse it... Is there a
> word or two missing or something?
Ya, I'll fix it
> Anyway, after digging through the source code (particularly
> web-server-unit.rkt), here's my understanding: If
> [host-root]/[file-root]/[servlet-root]/[url-path] refers to an existing file
> whose extension is ".ss", ".scm", ".rkt", or ".rktd", then the file is
> loaded and served as a servlet. (It's actually a bit more complicated,
> since it handles extra path elements after the servlet name.) For example,
> if host-root is ".", file-root is "htdocs", servlet-root is "servlets", and
> url-path is "foo.rkt", then if "./htdocs/servlets/foo.rkt" exists, it is
> served as a servlet, otherwise if "./htdocs/foo.rkt" exists, it is served as
> a file.
> Is this right? Can this be documented more clearly somewhere? (Or is it
> already?)
> Anyway, is there a way to customize this (e.g. to be able to map directory
> URLs to servlets) without having to recreate the entire chain of dispatchers
> from web-server@ by hand?
You shouldn't use web-server at . You should use serve/servlet where
stuff like this is totally trivial.
Jay
> --Doug
>
> _________________________________________________
> 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