[hunchentoot-devel] parameterp?

Tomasz Lipski tomek.lipski at gmail.com
Wed Dec 31 08:56:49 UTC 2008


2008/12/30 Erik Nomitch <enomitch at gmail.com>:
> Hi,
>
> I was wondering if there is a better way to test of a get/post parameter is
> set.  In the documentation, it says: (or NIL if there ain't no parameter
> with this name) .  But when it's not set and I do (hunchentoot:get-parameter
> "foo") and it DNE, I get a server error.  I'm using Hunchentoot 0.15.7 (SBCL
> 1.0.22).  Here is what I'm currently doing:
>
> (defun parameterp (str)
>   (dolist (x (hunchentoot:get-parameters))
>     (when (string= (car x) str)
>       (return-from parameterp t)))
>   nil)
>

Hi, can you submit error message and backtrace?

>From the top of my head, if the parameter is present in the submitted
form and not filled with
data it has "" value. When it is not present in the form
(get/post-parameter) returns nil (as the documentation says).

Simple test proves the point (works in interactive mode):

(create-prefix-dispatcher "/" (lambda () (format nil "test=~A"
(get-parameter "test"))))
(push * *dispatch-table*)
(start-server :port 8080)

The go to http://localhost:8080/ and http://localhost:8080/?test=1
and http://localhost:8080/?test=

Best regards,

Tomek Lipski




More information about the Tbnl-devel mailing list