page、pageContext、servletContext的区别
ServletContext是容器上下文,指当前的一个web应用的上下文
JSP网页本身,page对象是当前页面转换后的Servlet类的实例。从转换后的Servlet类的代码中,可以看到这种关系:Object page = this;在JSP页面中,很少使用page对象。
pageContext javax.servlet.jsp.PageContext 的实例,该对象代表该JSP 页面上下文,使用该对象可以访问页面中的共享数据。常用的方法有getServletContext和getServletConfig等.
- //使用pageContext 设置属性,该属性默认在page 范围内
- pageContext. setAttribute ("page" , "hello") ;
- //使用request 设置属性,该属性默认在request 范围内
- request. setAttribute ("request" , "hello");
- //使用pageContext将属性设置在request 范围中
- pageContext.setAttribute("request2″ , "hello" ,pageContext.REQUEST_SCOPE);
- //使用session将属性设置在session 范围中
- session.setAttribute("session" , "hello");
- //使用pageContext将属性设置在session范围中
- pageContext.setAttribute("session2″ , "hello" ,pageContext.SESSION_SCOPE);
- //使用application将属性设置在application范围中
- application. setAttribute ("app" , "hello") ;
- //使用pageContext 将属性设置在application 范围中
- pageContext.setAttribute("app2″ , "hello" , pageContext.APPLICATION_SCOPE);
- //使用pageContext 设置属性,该属性默认在page 范围内
- pageContext. setAttribute ("page" , "hello") ;
- //使用request 设置属性,该属性默认在request 范围内
- request. setAttribute ("request" , "hello");
- //使用pageContext将属性设置在request 范围中
- pageContext.setAttribute("request2″ , "hello" ,pageContext.REQUEST_SCOPE);
- //使用session将属性设置在session 范围中
- session.setAttribute("session" , "hello");
- //使用pageContext将属性设置在session范围中
- pageContext.setAttribute("session2″ , "hello" ,pageContext.SESSION_SCOPE);
- //使用application将属性设置在application范围中
- application. setAttribute ("app" , "hello") ;
- //使用pageContext 将属性设置在application 范围中
- pageContext.setAttribute("app2″ , "hello" , pageContext.APPLICATION_SCOPE);
总的来说,pageContext和page都是jsp中的隐含对象,pageContext代表jsp页面的上下文关系,能够调用、存取其他隐含对象;
page代表处理当前请求的时候,这个页面的实现类的实例。
page、pageContext、servletContext的区别的更多相关文章
- JSP内置对象——application,page,pageContext,config,Exception
application对象application对象实现了用户数据的共享,可存放全局变量.application开始于服务器的启动,终止于服务器的关闭.在用户的前后链接或不同用户之间的连接中,可以对a ...
- PageContext ServletContext ServletConfig辨析
上面三个东西都是什么关系呀? 先看图 注意几点 1 GenericServlet有两个init方法# 2 GenericServlet既实现了ServletConfig方法,它自己由依赖一个Servl ...
- <jsp:include page="${pageContext.request.contextPath/index.jsp" ></jsp:include> 引发的错误
路径引发的错误 如下使用项目路径对jsp页面进行获取,会报javax.servlet.ServletException: File "/web/dbwx/web/public/page_to ...
- servletconfig和servletContext的区别
1.servletConfig: 在Servlet的配置文件中,可以使用一个或多个<init-param>标签为servlet配置一些初始化参数.(配置在某个servlet标签或者整个we ...
- Ecstore后台中显示页面display,page,singlepage方法的区别?
dispaly 显示的页面不包含框架的其他页面,只是本身的页面(使用范围:Ecstore的前端.后端). page 显示的页面包含在框架的里面(使用范围:Ecstore的前端.后端). singlep ...
- JAVA-Servlet-ServletConfig 与 ServletContext 的区别
什么是ServletConfig? Servlet容器初始化一个servlet对象时,会为这个servlet对象创建一个servletConfig对象.在servletConfig对象中包含了serv ...
- JSP内置对象page/pageContext/Config/Exception
Config对象 config对象实是在一个Servlet初始化时,JSP引擎向它传递信息用的,此信息包括Servlet初始化时所要用到的参数(通过属性名和属性值构成)以及服务器的有关信息(通过传递一 ...
- jsp 中 include指令 用法, <%@ include file="..."%> 和 <jsp:include page="..." flush="true" />的区别?
原文链接https://blog.csdn.net/u012187452/article/details/51779052 1. 什么是jsp 文件? 个人理解. jsp 是一个容器,可以将我们编写 ...
- Page和list的区别 mybatis
先看一段代码 点击查看代码 @Override public Result findUserPage(PageParam pageParam) { Page<SysUser> page = ...
随机推荐
- Oracle数据库导入导出命令
在建立oracle客户端的前提下,Net Manager中配置了数据库的连接,使用此命令 导出数据 pauseecho 正在备份老数据库...pauseexp user/pwd@配置名称 file=d ...
- TCP协议疑难杂症全景解析
说明: 1).本文以TCP的发展历程解析容易引起混淆,误会的方方面面2).本文不会贴大量的源码,大多数是以文字形式描述,我相信文字看起来是要比代码更轻松的3).针对对象:对TCP已经有了全面了解的人. ...
- CCS3.3下执行优化
最近想研究一下CCS下的程序优化,之前也了解一些,现在查阅一下资料,整理一下. 当然优化有很多种,我本次先说的是执行优化方式. 首先打开我们自己的工程.工程文件若显示为黄色的,则表示此文件默认优化选项 ...
- 复制SharePoint列表项(SPListItem)到另一个列表
从理论上讲,有一个简单到难以置信的解决办法:SPListItem提供了一个CopyTo(destinationUrl)方法(可参考MSDN).不幸的是,这个方法似乎用不了.至少对我的情况(一个带附件的 ...
- 在windows下使用visual studio code建立.NET Core console程序
开发环境准备 下载vs code,.NET Core sdk: https://www.microsoft.com/net/core#windowscmd 目前最新版为code 1.8.1,.NET ...
- add number
// io.cpp #include <iostream> int readNumber() { std::cout << "Enter a number: &quo ...
- 仿东软OA协同办公服务管理系统
兼容IE6,7,8以上.GooleChrome.360及遨游等浏览器.系统特色:1.系统经过抗压测试.2.语音提示功能.3.支持office2007在线编辑.4.强大的图形化工作流程设计及文档编辑留痕 ...
- replaceWith() 和 replaceAll() 方法替换元素节点
$("#Span1").replaceWith("<span title='replaceWith'>陶国荣</span>"); $(& ...
- man curl_easy_perform(原创)
curl_easy_perform(3) libcurl 手册 curl_easy_perform(3) 名字 curl_easy_perform ...
- UVM的类库
[转]http://www.asicdv.com/ 一个UVM验证平台可以看成由多个模块组合在一起的,这和以前的verilog代码,以及verilog结合其它各种语言的验证手段在理念上是一样的,最大的 ...