作用域对象
1 pageContext
ageContext对象:它的生命周期即page域,指存储在pageContext对象的数据只在当前页面有效,当发生页面跳转时,则在pageContext域的数据进行销毁。
2 request
request对象主要用于处理客户端请求,同时request对象也是作用域对象,它的作用域范围是同一个请求。
![](https://img-blog.csdnimg.cn/img_convert/50cb297c5f8d41d0bfe38cce68211302.png)
request对象常用方法
![](https://img-blog.csdnimg.cn/img_convert/46e20f34758c49e994fd91255ee7814d.png)
3 session
session对象用来存储有关用户会话的所有信息,它的作用域范围是同一个会话
session对象常用方法:
1,void setAttribute(String key,Object value):以键/值的方式,将一个对象的值存放到session中
2,Object getAttribute(String key):根据名称去获取session中存放对象的值
4 application
application类似于系统的“全局变量”,用于实现用户之间的数据共享,它的作用域范围是在服务器一开始执行服务,到服务器关闭为止。
application 对象实现了javax.servlet.ServletContext接口
application对象的常用方法:
void setAttribute(String key,Object value):以键/值的方式,将一个对象的值存放到application中
void getAttribute(String key)通过键的方式,把对应的值取出来。
作用域对象测试
![](https://img-blog.csdnimg.cn/img_convert/78f993c2022b49e28a1ed36a5764d60e.png)
![](https://img-blog.csdnimg.cn/img_convert/35661abdc84848bb963fe78451dd9df3.png)
主页信息
![](https://img-blog.csdnimg.cn/img_convert/3a1fce1703dd4ff592bcb1ce4aa351d2.png)
![](https://img-blog.csdnimg.cn/img_convert/c2676fd2dd98463182f2cd2c6f71c162.png)
添加信息操作
![](https://img-blog.csdnimg.cn/img_convert/750a5d5963e143088094b47430596a57.png)
![](https://img-blog.csdnimg.cn/img_convert/5b38f3aef5c442258466d6cfb2b13fba.png)
![](https://img-blog.csdnimg.cn/img_convert/fa28b4990df547fa82af8c4659c31db7.png)
![](https://img-blog.csdnimg.cn/img_convert/155a9bbe1b2e4de881eefc153e70f224.png)
添加成功
![](https://img-blog.csdnimg.cn/img_convert/872f31a52b4d446f9f0649a9e1411b7d.png)
删除信息操作
![](https://img-blog.csdnimg.cn/img_convert/e7c572b11a0a4549b8e654a63284fd07.png)
![](https://img-blog.csdnimg.cn/img_convert/638ab321faf74df7baf569c8a1319df9.png)
![](https://img-blog.csdnimg.cn/img_convert/5ab472e983704124a958956ced7cc76f.png)
原来的商品信息
![](https://img-blog.csdnimg.cn/img_convert/509ddf666f3f478b987a89e5837709a0.png)
现在的商品信息
![](https://img-blog.csdnimg.cn/img_convert/a94d1045a8874290b61535c243cd55c6.png)
数据库里
![](https://img-blog.csdnimg.cn/img_convert/b9ec37c1be5e45bb95cc81d097d0f855.png)
修改信息操作
![](https://img-blog.csdnimg.cn/img_convert/89b6df433f4f4b72a7cb8c8413d4fe2f.png)
![](https://img-blog.csdnimg.cn/img_convert/951d07ee4ad64949ac9e7587346dabca.png)
![](https://img-blog.csdnimg.cn/img_convert/6dc2f0feb1e2474aa16da691d052dfe1.png)
![](https://img-blog.csdnimg.cn/img_convert/613414d8c4a843bdad27fc09ef073a8f.png)
![](https://img-blog.csdnimg.cn/img_convert/35e5a713ee854869a0d4b0d4cc7e76ff.png)
![](https://img-blog.csdnimg.cn/img_convert/466dcc0d32274e409f277541fa6e062d.png)
![](https://img-blog.csdnimg.cn/img_convert/24f529f0fe1646c7b2c5df5db05ea110.png)
点击修改即可修改商品信息
![](https://img-blog.csdnimg.cn/img_convert/9efeb4196fc5474193736b80b8f90fc2.png)
模糊查询操作
![](https://img-blog.csdnimg.cn/img_convert/a54407b6044f43db98783e0fc270ef4a.png)
![](https://img-blog.csdnimg.cn/img_convert/d1ccad1ea5574c8081add81345f73e4b.png)
![](https://img-blog.csdnimg.cn/img_convert/9e2853206b85409ebb4fcc8e56f255f5.png)
![](https://img-blog.csdnimg.cn/img_convert/37b14a7b25db418bbe09eb0c56fc3e9a.png)
在搜素框里输入商品的一些信息即可查询到有的信息
![](https://img-blog.csdnimg.cn/img_convert/e7d727478284476ea45054d8cbd1fc12.png)