九大内置对象:
out 最常用的Println()方法,输出
config 基本没啥用
page 当前jsp页面实例跟this一样
pageContext 只有当前页面才可以获取
exception 错误页可以使用它
request 与Servlet中request一样没有区别
response 与Servlet中resqonse一样
application 就是servletcontext对象
session 就是HttpSession对象
注意:pageContext它不仅只是域对象,而且还可以操作所以域对象。还可以获得其他对象
pageContext.setAttribute(String name, value); 设置当前页指定名字的值
pageContext.getAttribute(String name, value); 获取当前指定名字的值
pageContext.setAttribute(String name, value,int scope);设置指定范围的值
pageContext.getAttribute(String name,int scope); 获取指定范围的数据
scope来指定范围,在PageContext类中包含四个int类型的常量表示四个范围。
scope:
PAGECONTEXT_SCOPE 当前页
REQUEST_SCOPE 一次请求范围
SESSION_SCOPE 一次回话(只要浏览器不关,都有效)
APPLICATION_SCOPE 服务器上下文中(只要服务器不关闭,或崩溃都有效)
常用方法
pageContext.getServletContext().getContextPath() ; 获得当前项目名称
<jsp:forward page="/1.jsp"></jsp:forward>
页面跳转服务器另外一个页面