Java Servlets   «Prev 

HTTP is stateless

By stateless, I mean that there is no continuing interaction between a user and a server. Each request is discrete.
Picture this: It's an afternoon like any other, and you're sitting by your desk phone, bracing yourself for a series of phone conversations. A call comes in, you discuss the matter at hand, and the caller hangs up. Moments later, the phone rings again. It's the same person, but they don't remember the earlier conversation. You find yourself starting from scratch - every single time.
Welcome to the world of HTTP, or Hypertext Transfer Protocol. Just as in the rather absurd phone scenario painted above, HTTP is inherently stateless. This means that each request from a client to a server is treated as an independent transaction, unrelated to any previous requests. When you're browsing a website, every click, every page load, every image fetched is a separate HTTP request, and each one is a blank slate in the eyes of the server.
Imagine a phone conversation where each question is followed by a disconnect, and a new call has to be placed for each subsequent question, with no recollection of the previous calls. It's a very efficient system in one sense, reducing the demand for continuous connections and freeing up resources for other users. But it can also feel disjointed and inefficient, like trying to complete a jigsaw puzzle without being able to see the image you're assembling. But here's where the story gets interesting. Just as humans naturally seek continuity in conversations, the digital world also found a need for some kind of 'memory'. The solution was cookies - small pieces of data stored in your browser that can be sent back to the server with each request. They're like sticky notes, helping the server remember who you are and what you've been up to on a website. In a phone conversation analogy, it's like having a personal assistant who takes notes during every call and can brief you when the same caller rings back.
So, while HTTP, at its core, is like having dozens of separate phone calls, the use of cookies and similar technologies creates the illusion of one ongoing conversation. These elements of statefulness, grafted onto the stateless HTTP, make our online interactions more seamless, enabling things like shopping carts, personalization, and user accounts. In the ceaseless chatter of data that makes up our internet today, each HTTP request might be a fresh start, but it's never really a stranger's call.

HTTP Evolution

HTTP began its life as an anonymous, stateless, request/response protocol. A request came from a client, was processed by the server, and a response was sent back to the client. Little information was available to the web server to determine what user sent the request or to keep track of a sequence of requests from the visiting user. Modern web sites want to know more about users on the other ends of the connections and be able to keep track of those users as they browse. Popular online shopping sites personalize their sites for you in several ways:
  1. Personal greetings
  2. Welcome messages and page contents are generated specially for the user, to make the shopping experience feel more personal.
  3. Targeted recommendations
  4. By learning about the interests of the customer, stores can suggest products that they believe the customer will appreciate.
  5. Administrative information on file
  6. Online shoppers hate having to fill in cumbersome address and credit card forms over and over again.
Some sites store these administrative details in a database and once they identify you, they can use the administrative information on file, making the shopping experience much more convenient.

Java Servlets