68
CHAPTER 5. EXAMPLES OF SCHEME SERVLETS
; counter.servlet
(let ((count
(+ 1
(read from file (servlet file request "count") 0))))
(write to file (servlet file request "count") count)
{counter

You are visitor number [count]

 }
)
Figure 5.2: A simple counter program
(Vn En))
F1
F2
...
F
)
where the Ei are evaluated first and their values stored temporarily the variables
Vi, then the expressions Fi are evaluated and finally the value of expression F is
returned.
1
The only reason we would evaluated the Fi is that they have some
side effect like writing something into a file on the disk or sending an email
message, or updating a database, etc.
This servlet illustrates the use of three new procedures:
  (read from file FILENAME DEFAULT VALUE) this reads a scheme terms
from the specified FILENAME, and if no such file exists then it returns
the DEFAULT VALUE instead.
  (write to file FILENAME VALUE) this writes the specified VALUE to
the specified FILE, and if the FILE does not already exist then it creates
it.
  (servlet file request "XYZ")   this returns the file path of the cur 
rent servlet with the suffix   XYZ  appended to it. This file path can be
used to read or write to this new file. The advantage of this is that the
servlet can be moved to another place on the server and will create a use
a counter in the same directory! This is very similar to the advantages of
using relative file names rather than explicit URLs when writing websites.
1
Actually, one can have several expressions between Vi and Ei as well, and these expressions
are evaluated sequentially.




  

Home

About Services Network Support FAQ Order Contact
 

Tomcat Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved