4.1.2 Stateless servers
Web servers are what are known as stateless servers. What this means is that in their pure form they keep no memory of what has previously happened to them between requests; for example, when a request is processed by a web server for a page they have no direct knowledge about whether the page request was made by the same browser that asked for a previous page to be returned.
While this was not serious when web servers were being mainly used for dispensing documentation (their original use) it is a serious problem in e-commerce. One example of this is the shopping cart, or as it is known in the United Kingdom, the shopping trolley. When you visit an e-tailer and purchase goods you interact with a simulation of a shopping cart which keeps details of the goods that you have purchased. At the end of your interaction a web page, often known as a checkout page, will display the contents of the shopping cart and present you with the monetary total of your purchases. web servers as originally envisaged are unable to do this as they have no knowledge of any previous visit: they would not be able to remember the previous purchase.
(This is not the full story: there is some indirect knowledge. web servers will keep details of the accesses to their stored pages in a simple sequential file known as a log file which is used for marketing purposes and for optimising the web server.)
In the comparatively early days of the web this was seen to be a problem and a form of programming known as Common Gateway Interface programming was developed which enabled a web server to have a memory. There are a number of other, more recent technologies which have been developed to cope with this problem. The first is cookies; these are chunks of data which are stored on the computer running the web browser and which can be accessed by the browser throughout their interaction with a particular website. Such cookies can, for example, store the data associated with a shopping cart. Another technology used to store state is servlets; this is a technology, which employs cookies, and which is associated with Java; it enables the programmer to develop reusable code that can be plugged into a server and which keeps data persistently in the web server.