On Tuesday, June 17, 2003, at 04:19 AM, Cristina Gema Muñoz Maya wrote:
Hello,
I'm sorry because i don't know how to write in english very
well. I have a problem with cl-http. I am begining with a simple
example, but it is imposible for me to do nothing. I don't know if the
sintaxis is good, or if i have to put something more.
First, I have a html page: siidepe.html (with a post method):
<HTML>
<body>
<FORM ACTION="p" METHOD="POST"
enctype="application/www-form-url-encoded">
<INPUT TYPE="text" NAME="nombre" SIZE="10" VALUE="">
<input type="submit" NAME="boton" VALUE="ENTRAR">
</FORM>
</BODY>
</HTML>
And the file p.lisp:
For starters, there are some problems with the lisp code in this file.
The main ones are that you have some variables that are not bound.
This is addressed in some of the comments below that I added to the
code. Currently this function doesn't get called, but that problem
will also be addressed.
(defmethod respond-to-html-form ((url url:http-form) stream
query-alist)
(bind-query-values (nombre)
(url query-alist)
)
^
Closing the BIND-QUERY-VALUES form here ends the scope in which the
variable NOMBRE has a value bound to it. You cannot reference the
variable after this point. What you will need to do is move this close
parenthesis to the end of the function.
(with-successful-response (stream :html :expires
(url:expiration-universal-time url)
:cache-control
(url:response-cache-control-directives url) :content-location url
:content-language (languages url))
(with-html-document (:declare-dtd-version-p t
:stream stream)
(with-document-preamble (:stream stream)
(declare-base-reference url
:stream stream)
(declare-title title :stream
stream)
^^^^^
The variable TITLE doesn't have any binding. You will have to
establish this variable and give it a value. That suggests the need
for a LET statement in your function. The other alternative is to just
use a literal string, but having a LET at the beginning of the function
will make it easier to modify or adapt to another purpose.
)
(with-standard-document-body (:stream
stream)
(write-string nombre stream)
)
)
)
)
OK, the reason that you aren't seeing the HTML form page is that
CL-HTTP doesn't know where to find it. The EXPORT-URL function has to
tell it that. But in the example you provided, there is only a
response-function. That response function will be called when the form
is POSTed. To provide the form with the GET (in order to see it in
your browser in the first place), you need to provide a pathname to
your file siidepe1.html)
(export-url "http://siidepe1.html" ;where the form computed
dynamically is going to be located
^^^^
I don't have time to check the documentation for sure, but it seems
that your URL is missing a host element. What I don't recall offhand
is whether CL-HTTP will default the host into the URL for you. In any
case, you will probably want to use the #u reader macro in front of the
URL string. You might want to try something as simple as
#u"/siidepe1.html" for the URL argument.
:html-form
:expiration '(:no-expiration-header)
Here is a good place to put the pathname telling CL-HTTP where to find
the form page:
:pathname "/cl-http/sidepe/siidepe.html"
:response-function #'respond-to-html-form
:public t
:language :en
:keywords '(:cl-http :demo)
:documentation "Prueba.")
The files are located:
/cl-http/sidepe/siidepe.html
/cl-http/siidepe/p.lisp
In internet explorer , i put the url:
http://umbriel.uma.es:8000/siidepe/siidepe.html, to see the form, but
when i do the submit, it doesn't create the page dynamically. I don't
know if i have
to compile the file p.lisp,with this extension (.lisp) or with a
different one, and what is the exactly path to upload the files.
I expect your answer, thank you very much.
Cristina, my email: cristinagmm@xxxxxxxxxxx
_________________________________________________________________
Accede al romance onine. Descubre gente que busca a otra gente en MSN
Amor & Amistad. http://match.msn.es/
|