aspose file tools*
The moose likes Servlets and the fly likes why http stateless? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "why http stateless?" Watch "why http stateless?" New topic
Author

why http stateless?

Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100

why http is stateless protocol.......
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2409
    
  28

A stateless protocol is more efficient than a stateful protocol. In a stateful protocol, (like TCP/FTP) the "connection" has to be open to keep the state. Each open connection costs resources on the server. Remember, that HTTP was really designed to serve up static files very efficiently. Having dynamic pages that are computer generated is something that was bolted on to HTTP. Dynamic pages require state, static pages don't.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

It's stateless because there is no information stored in the HTTP server from one request to the next. That's simply the definition of "stateless".
Ritesh raushan
Ranch Hand

Joined: Aug 29, 2012
Posts: 100


i know.....i asked why http is stateless why not stateful ...we can also convert from stateless to stateful(session tracking)..

what's reason ....
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

Jayesh and Paul already answered your question. What more are you looking for?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

To tell the truth, I only guessed at the question because I didn't really understand what it meant.

Here's an analogy. Question: "Why do we wear shoes on our feet?"

There's nothing wrong with the question in terms of grammar, but what is it asking about? It might be asking "Why do we wear shoes on our feet instead of on our hands?" Or it might be asking "Why do we wear shoes, and not glasses, on our feet?" Or it might be asking "Why do we wear shoes on our feet instead of nothing?" Sure, you might say that some of those interpretations are ridiculous because we all know what shoes and feet are. But when you translate it to a context where we're talking about protocols and state, where the person asking the question might not know what those things are, all of the possible meanings come into play, no matter how ridiculous they may seem to somebody who does know what they are.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

Here's another possible answer: HTTP is a stateless protocol because the designers of HTTP decided it should be one.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

Jayesh A Lalwani wrote:A stateless protocol is more efficient than a stateful protocol. In a stateful protocol, (like TCP/FTP) the "connection" has to be open to keep the state. Each open connection costs resources on the server. Remember, that HTTP was really designed to serve up static files very efficiently. Having dynamic pages that are computer generated is something that was bolted on to HTTP. Dynamic pages require state, static pages don't.


i see that you are saying that STATEFUL PROTOCOL , THE CONNECTION HAS TO BE OPEN. so that means in stateless protocol like http connection IS NOT KEPT OPEN. but i have read that in http 1.1 we have something called PERSISTENT CONNECTIONS, which keeps the connection alive. so is http statefull ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why http stateless?