JSP中的内置对象
简述:JSP内置对象,又称为隐式对象,在JSP中,不需要创建就可以创建使用的变量,在JSP中一共有9个内置对象。
request | javax.servlet.http.HttpServletRequest |
---|---|
response | javax.servlet.http.HttpServletResponse |
application | javax.servlet.ServletContext |
session | javax.servlet.http.HttpSession |
pageContext | 用来代表整个jsp页面,通过pageContext对象可以获取jsp的其它的隐式对象 |
config | Javax.servlet.ServletConfig |
out | 是javax.servlet.jsp.Jspwriter类的实例,用来在response对象中写入内容 |
exception | 只能在错误页中可以使用 |
page | 表示当前jsp页面的实例,和this相同 |
pageContext
pageContext不仅可以获取其它隐式对象,还提供了存储数据的功能(域对象)
pageContext 对象那存储数据通过操作属性来实现
方法名称 | 功能描述 |
---|---|
void setAttribute(String name,Object value,int Scope) | 设置pageContext对象的属性 |
Object setAttribute(String name,Object value) | 获取pageContext对象的属性 |
void removeAttribute(String name,int Scope | 删除指定范围内名称为name的属性 |
void removeAttribute(String name) | 删除所有范围内名称为name的属性 |
Object findAttribute(String name) | 从四个域对象中查找名称为name的属性,会按照page,request,session,application的顺序依次进行查询,如果找到,返回的属性name对应的value,否则返回null |