Chrome开发者工具Network标签页中观察到的set-cookie jsessionid是什么东西
在Chrome開發(fā)者工具里經(jīng)常能觀察到HTTP響應(yīng)里包含的字段:
Set-Cookie: JSESSIONID= XXX
之后,就能在客戶端cookie里觀察到JSESSIONID=后面的值。
根據(jù)Google搜索的結(jié)果:
https://javarevisited.blogspot.com/2012/08/what-is-jsessionid-in-j2ee-web.html
這篇博客有詳細(xì)介紹:
What is JSESSIONID in JSP-Servlet
JSESSIONID是由Servlet容器比如Tomcat或Jetty等生成的,用于基于HTTP協(xié)議的J2EE web應(yīng)用中進(jìn)行session管理。
因?yàn)镠TTP是一種無狀態(tài)的協(xié)議,Web服務(wù)器無法區(qū)分來自同一個(gè)客戶端的兩個(gè)不同請(qǐng)求,因此需要Session管理機(jī)制,具體實(shí)現(xiàn)有Cookie和URL Rewriting等。
JSESSIONID is a cookie generated by Servlet containers like Tomcat or Jetty and used for session management in J2EE web application for HTTP protocol. Since HTTP is a stateless protocol there is no way for Web Server to relate two separate requests coming from the same client and Session management is the process to track user session using different session management techniques like Cookies and URL Rewriting.
采用Cookie會(huì)話管理的服務(wù)器會(huì)在客戶端第一次請(qǐng)求時(shí)生成JSESSIONID,然后返回給客戶端。客戶端隨后每次請(qǐng)求都會(huì)把這個(gè)JSESSIONID附在HTTP請(qǐng)求頭部。
比如我們下面這個(gè)例子,是不是看到了前面出現(xiàn)在HTTP response set-cookie字段里的JSESSIONID值,在第二個(gè)接下來的請(qǐng)求里出現(xiàn)在HTTP request field上了?
If a Web server is using a cookie for session management it creates and sends JSESSIONID cookie to the client and then the client sends it back to the server in subsequent HTTP requests. JSESSIONID and session management is a not only a popular Servlet interview question but also appear in various JSP interviews. Along with What is JSESSIONID interviewer are also interested in when and howJSESSIONID is created in Servlet and JSP which we will see in next section.
如果客戶端瀏覽器禁掉了cookie,那么服務(wù)器仍然可以生成JSESSIONID,只不過以URL重寫的技術(shù),把這個(gè)JSESSIONID值傳回客戶端:
https://localhost:8443/supermart/login.htm;jsessionid=1A530637289A03B07199A44E8D531427
要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":
總結(jié)
以上是生活随笔為你收集整理的Chrome开发者工具Network标签页中观察到的set-cookie jsessionid是什么东西的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: gta5珠宝店位置在哪
- 下一篇: 利用微信登录掘金网站的HTTP请求分析