JSP九大内置对象
request | 请求对象 |
response | 响应对象 |
session | 会话对象 |
application | 应用程序对象 |
pageContext | 页面上下文对象 |
config | 配置对象 |
exception | 异常对象 |
page | 页面对象 |
out | 输出对象 |
Request, Session, Application的区别
- 相同点
都可以储存属性,属性名可以相同但有 优先级 (Requset>Session>Application)
application.setAttribute("msg",message); //setAttribute("属性名",属性值);
session.setAttribute("msg",message);
request.setAttribute("msg",message);
//当页面使用EL表达式 ${msg} 时,显示的是request的属性值
- 不同点
Request中储存属性数据仅仅在一个请求中可用
Session中储存的属性数据在Web项目的会话有有效期内可用
Application中储存的属性数据在整个Web项目可用,有效期最长,范围最广