Mobile HTTP Session
Last Update:2015-06-04
Source: Internet
Author: User
<span id="Label3"></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">Jsessionid settings are carried in the cookie header, and the server gets the corresponding session based on this sessionid instead of recreating a new session (except for this session failure).</p></p><p><p><br></p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">Take the Java.net.HttpURLConnection initiation request as an example:</p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">To obtain a cookie:</p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">URL url = new URL (requrl);<br>HttpURLConnection con= (httpurlconnection) url.openconnection ();<br>Get Sessionid.<br>String cookieval = Con.getheaderfield ("set-cookie");<br>String sessionid;<br>If (cookieval! = Null) {<br>SessionID = cookieval.substring (0, cookieval.indexof (";"));<br>}</p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">SessionID value Format: jsessionid=ad5f5c9eeb16c71ec3725dbf209f6178, is a key-value pair, not a Single-finger value</p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">Send Settings Cookie:</p></p><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);"><p style="word-wrap: break-word; margin-top: 0px; margin-bottom: 0px; padding: 0px; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; white-space: normal; background-color: rgb(255, 255, 255);">URL url = new URL (requrl);<br>httpurlconnectioncon= (httpurlconnection) url.openconnection ();<br>If (sessionid! = Null) {<br>Con.setrequestproperty ("cookie", sessionid);<br>}</p></p><p><p><span style="word-wrap: break-word; color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size: 14px; line-height: 21px; background-color: rgb(255, 255, 255);">As long as the SessionID is set up, the Web server will automatically search for the corresponding session when it accepts the request, thus guaranteeing the session in the same Conversation.</span></p></p><p><p></p></p><p><p><br></p></p><p><p>Mobile HTTP Session</p></p></span>