Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>HTTP is stateless. Meaning that the data returned by the server does not depend on any previous actions by the user. Cookies and other non-HTTP methods is what makes the web appear to be stateful, enabling user to for example log-in and out on websites.</p> <p>Check out: <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html" rel="nofollow">http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html</a></p> <p>For an application developers, it IS stateless always. </p> <p>For end users it is appears to be statefull</p> <p>Now,</p> <p>Each HTTP request results in a new invocation of a servlet (i.e., a thread calling the servlet’s service and doXxx methods), regardless of whether the connection is keep-alive or not. </p> <p><strong>EDIT:</strong></p> <p>HttpSession object is used to set information related to a specific session say, the number of products in a cart for the current session. Note that session gets closed if the browser is closed or if you clear the cookies.</p> <p>How does the webserver know that its the same session?</p> <p>Webservers sends a sessionId to the browser in the form of cookie. And, the browser sends the cookie having sessionId back to the server for subsequent requests.</p> <p>How does the browser identifies which cookies to send for a link/request? </p> <p>It is based on the these parameters. If the request matches these parameters the browser sends that particular cookie:</p> <p>Domain: The domain name to which the request is made. </p> <p>Path: If the context root path name is same. </p> <p>Secure: Server sends if the given cookie if it can be sent on this non-secure channel</p> <p>If cookies are disabled then it uses URL-rewriting. </p> <p>Is it possible to retain the session even after the browser is closed and opened? Yes. The answer is cookie + DB + Googling :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload