Note that there are some explanatory texts on larger screens.

plurals
  1. POCan not understand the session object behavior
    text
    copied!<p>I am confused on the documentation of the <a href="http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.1/api/javax.servlet.http.HttpSession.html" rel="nofollow">javax.servlet.http.HttpSession</a>.<br> It says: </p> <blockquote> <p>Sessions are used to maintain state and user identity across multiple page requests. A session can be maintained either by using cookies or by URL rewriting.</p> </blockquote> <p>Now both cookies and URL rewriting are handled by application code in server (i.e. our code). </p> <p>Then it says relating to when a session is considered as <code>new</code>: </p> <blockquote> <p>The server considers a session to be new until it has been joined by the client. Until the client joins the session, the isNew method returns true.A value of true can indicate one of these three cases:<br> 1. the client does not yet know about the session<br> 2. the session has not yet begun<br> 3. the client chooses not to join the session. This case will occur if the client supports only cookies and chooses to reject any cookies sent by the server. If the server supports URL rewriting, this case will not commonly occur.</p> </blockquote> <p>I am not clear on when it is considered/meant that the <code>client has joined the session</code>. </p> <p>I mean if I don't use cookies from my web application (or URL rewriting) and I have the following: </p> <ol> <li>POST from IP A to server</li> <li>200 OK from server to A</li> <li>POST from IP A to server </li> </ol> <p>In step 3 will the <code>session.isNew()</code> return true or false? It is not clear to me from the doc.<br> Will it return false (i.e. the session is not new) and I will have to call <code>session.invalidate()</code> in order to create a new session?<br> The reason this confuses me more is because I am debugging a piece of code where the client is an HTTP application but not a web brower and I see that in step 3 the <code>session.isNew()</code> does not return <code>true</code> although there is no cookies or url rewriting in the server code.<br> So I can not figure out what is going out under the hood.<br> Any info that could help understand this?</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