Consequences of Stateless Interactions and HTTP Information
Java Servlet API
HTTP is only one of many protocols in use on the Internet.
There are literally hundreds of ways for two pieces of software to exchange information over the network.
One way to differentiate them is to characterize them as either
stateful or
stateless.
In a stateful exchange of information the client and the server maintain their connection until all communication is finished and the connection is specifically terminated. It is rather like a telephone call. Say I want to call you and get the phone numbers of two of our mutual friends.
The purpose of these diagrams is to give you the general idea. Now if I were to get the same information from you in a stateless way, I would have to tell you everything you needed to know in every request. We would not keep a connection or session going between requests.
HTTP is stateless. Whenever a browser requests a file, the server sends back the file and the connection drops.
If the user follows a link on that page to a file on the same server, the browser contacts the server again and asks for that new file, but the server does not know that the browser just requested a file moments ago. Each request is completely independent.
The HTML for your Contact page is likely to be the same no matter how many times this user has been to your site.
But if people are buying books or clothes, you need to know that this browser request is from the same person who has already ordered $200 worth of your product, and now they want to order more. This is called maintaining state. That way, you can give people a running total of their order or any number of personalized pages that are right for them. In the next lesson, CGI server-side technology will be discussed.