Mobile HTTP Session

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.