cookie的概念
a) 为什么引入cookie
HTTP是无状态协议,服务器不能记录浏览器的访问状态,也就是说服务器不能区分出两次请求是否由一个客户端发出。
b) cookie的作用
Cookie实际上就是服务器保存在浏览器上的一段信息。浏览器有了Cookie之后,每次向服务器发送请求时都会同时将该信息发送给服务器,服务器收到请求后,就可以根据该信息处理请求。
cookie的应用
a) 网上商城购物车
b) 用户登录状态的保持
cookie的原理
1) 第一次向服务器发送请求时在服务器端创建一个Cookie对象
2) 将Cookie对象发送给浏览器
3) 以后浏览器再发请求时就会携带着该Cookie对象
4) 服务器根据不同的Cookie对象来区分不同的用户
cookie创建以及设置转发路径
servlet端的
html端
cookie的获取
servlet端的
html端
cookie的持久化
servlet端
html端