I'm encountering some strange behavior when using parameters with my
(stateless) web servlets.

I want to check the value of a cookie every time a request is made to my
server and make a Racket value derived from the cookie's value available
for use within the servlet code. Since this value shouldn't be stored in
the continuation — it should be generated fresh for every request — it
seemed like writing a dispatcher (in the sense of serve/launch/wait, not of
dispatch-rules) was the right place to do this. Since the servlet code
itself does not need to (and indeed should not) modify the value, I thought
I could use a standard parameter to store the value. Essentially I have a
function shaped like this:

(define ((wrap-dispatcher inner) connection request)
  (parameterize ([my-param ...])
    (inner connection request)))

where inner is a dispatcher produced by dispatch/servlet.

All of the work being done by wrap-dispatcher seems to be happening
correctly (e.g. setting and reading the cookie), but within the servlet
itself, the parameter seems to get "stuck" on the first value installed by
wrap-dispatcher after the server is launched (which is not the default
value for the parameter).

I'm not sure why this is happening. I understand that plain parameters
cannot be set within stateless servlets for serialization reasons (hence
the existence of web-parameters), but I didn't think that impacted code
that merely accesses the value of a parameter.

More urgently, I'm not sure how to fix it. Would making my-param a web
parameter solve the problem (without storing the value in the
continuation)? Or is there some other method that should be used for this
sort of per-request work?

Thanks,
Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to