48
CHAPTER 4. SCHEME SERVLETS
gram which simply returns the date. We assume this is stored in a file named
 date.servlet  stored in the  scheme  folder of the server directory. This file
contains the following lines:
; date.servlet    returns the current time and date
; lines beginning with a semicolon are comments
(Date.)
The first two lines are comments (as they begin with a semicolon) and so are
ignored by Scheme. The second line is a Scheme expression which returns the
current local date and time
1
. To view this servlet, one must visit the URL:
http://MY.DOMAIN.EDU:8080/scheme/date.servlet
where MY.DOMAIN.EDU is the domain name of the scheme server you are using.
If you have installed a Scheme server on your home computer, then you can use
the IP address of your home computer in place of MY.DOMAIN.EDU or you can
use the  self loop  IP address
127.0.0.1
which always refers to the computer itself. Visiting this address with a standard
browser will bring you to page that contains the current time and date:
Sun Jan 20 07:46:44 EST 2002
The expression (Date.) is an example of a Scheme expression. It is an invoca 
tion of the Date. procedure with no arguments.
4.2
Arithmetic Expressions in Scheme
Another simple example of a servlet is the following which we assume is stored
in a file named sumToTen.servlet:
; sumToTen.servlet    this returns the sum of 1 to 10
(+ 1 2 3 4 5 6 7 8 9 10)
When one visits this servlet with a browser, the server evaluates this expres 
sion and applies the addition operator + to the arguments that follow it in the
parenthesized list. The result that is return to the browser is the number
55
In a way the scheme server can be viewed as a calculator, where you put the
expression you want to compute into a file and when you view the file with a
browser it will evaluate that expression and return your answer. A slightly more
complex example is the following:
1
Actually, (Date.) returns a  Date  object representing the current time and date. This
Date object is turned into a string representing the date in the local dialect.




  

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