<br><div class="gmail_quote">On Thu, Aug 6, 2009 at 9:02 PM, Jay McCarthy <span dir="ltr"><<a href="mailto:jay.mccarthy@gmail.com">jay.mccarthy@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
If you call next-dispatcher, the "current" request will be delivered<br>
to the next dispatcher (such as the static file handler.) If you want<br>
a different one, you could create your own dispatcher with a similar<br>
for that uses a different request (maybe I should do that...?) Another<br>
option is to return a redirect response.</blockquote><div><br>It seems that I am not understanding dispatcher well enough to use it - can (next-dispatcher) be called from within a servlet? I am getting the following error:<br>
<br><div style="margin-left: 40px;">(file "C:\\Local\\PLT4.1.3\\collects\\web-server\\dispatchers\\dispatch-servlets.ss") broke the contract (-> url? exn? response?) on servlet-error-responder; expected <exn?>, given: #<exn:dispatcher><br>
</div> <br>What I did was basically test to see if this is a path I wanted to handle, and throw exn:dispatcher... is there another way of using it?<br><br><div style="margin-left: 40px;">(define (start request)<br> (let ((path-list (map path/param-path (url-path (request-uri request)))))<br>
(cond ((equal? path-list '("test"))<br> `(p "this is a test resopnse"))<br> (else ;; let web-server handle the path.<br> (next-dispatcher)))))<br></div><br>The servlet is run through serve/servlet.<br>
<br>;; web.ss<br>#lang scheme/base<br><br>(require web-server/servlet<br> web-server/servlet-env<br> "servlet1.ss"<br> )<br>;; why did the current-directory get reset?<br>(thread (lambda ()<br>
(serve/servlet start #:port 8800<br> #:servlet-path "/"<br> #:launch-browser? #f<br> #:listen-ip #f<br> #:servlet-namespace '( "servlet1.ss")<br>
#:servlets-root (current-directory)<br> #:servlet-regexp #px".*"<br> #:server-root-path (current-directory)<br> #:extra-files-paths (map string->path '("c:\\data\\ajax"))<br>
)))<br><br>;; servlet1.ss<br>#lang scheme/base<br>(require (only-in web-server/servlet current-servlet-continuation-expiration-handler)<br> web-server/managers/lru<br> web-server/http/request-structs<br>
web-server/dispatchers/dispatch<br> net/url<br> )<br><br>(define interface-version 'v2)<br><br>(define manager<br> (create-LRU-manager current-servlet-continuation-expiration-handler<br> 60<br>
3600<br> (lambda () #t)<br> #:initial-count 1 <br> #:inform-p (lambda _ (void))))<br><br>(define (start request)<br> (let ((path-list (map path/param-path (url-path (request-uri request)))))<br>
(cond ((equal? path-list '("test"))<br> `(p "this is a test resopnse"))<br> (else <br> (next-dispatcher)))))<br><br>(provide (all-defined-out))<br><br><br><br><br></div>
</div>