;; scheme.sss ;; (lambda (httpservlet) (define (read-all in) (define (drain in sbuffer) (let ((line (.readLine in))) (if (eq? line #null) (.toString sbuffer) (drain in (.append (.append sbuffer line) "\n"))))) (drain in (java.lang.StringBuffer.))) (define (getRealPath servlet File) (.getRealPath (.getServletContext (.getServletConfig servlet)) File)) (define (doGet request response) (define filename (getRealPath httpservlet (.getServletPath request))) (define body (string->expr (read-all (java.io.BufferedReader. (java.io.FileReader. filename))))) (define proc `(lambda(request response httpservlet out) (let ((b ,body)) (if (not (equal? #null b)) (.println out b))))) (let ((out (.getWriter response))) (.setContentType response "text/html") (jsint.Procedure.tryCatch (lambda() ((eval proc) request response httpservlet out)) (lambda(e) (.setContentType response "text/html") (display (list "SERVLET ERROR
") out) (.printStackTrace e out) (display (list "") out) )))) (define (doPost request response) (.doGet httpservlet request response)) ;; store scheme procedures into the httpservlet (.do_get$ httpservlet doGet) (.do_post$ httpservlet doPost) ;; finally we load in the library files (load (getRealPath httpservlet "lib/files.scm")) (load (getRealPath httpservlet "lib/forms.scm")) (load (getRealPath httpservlet "lib/getformvalues.scm")) (load (getRealPath httpservlet "lib/mail.scm")) (load (getRealPath httpservlet "lib/servlet.scm")) (load (getRealPath httpservlet "lib/tables.scm")) (load (getRealPath httpservlet "lib/db0.scm")) (load (getRealPath httpservlet "lib/db.scm")) )