4.6. SERVLET PARAMETERS
53
(string append
{the sum of 5 and 7 is }
(+ 5 7)
{ the difference is }
( 5 7) )
both of these return the string
"the sum of 5 and 7 is 12 the difference is 2"
Thus, the quasi string notation is just a short hand for the string append
expression.
4.6
Servlet parameters
Next we show how to create a simple kind of interactive web page in which you
can pass values to the servlet which will then be used to generate the webpage
returned to the browser.
Our first example is the following simple echo servlet
; echo.servlet this returns the value of the
; servlet parameter "a"
(servlet (a)
a)
If we visit the URL
http://SERVER.DOMAIN:8080/scheme/echo.servlet?a=HELLO!
Then the server will call the echo.servlet and will pass it the parameter string
?a=HELLO!. The expression
(servlet (a) EXPR )
will extract the string HELLO! and bind it to the variable a. It will then evaluate
the body (in this case a itself, which it returns to the browser. Thus, if we visit
this URL, we will get a page containing
HELLO!
Note that we would get the same result if we visited the following URL:
http://SERVER.DOMAIN:8080/scheme/echo.servlet?b=zz&a=HELLO!&c=7
This URL shows how to pass three values to a servlet. Our servlet is only
interested in the value for the parameter a so it ignores the other two parameters.
Php Web Hosting Introduction to Interactive Web Design Php Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |