Accessing Scoped Variables
To permit the JSP page to access the data, the servlet needs to use setAttribute to store the data in one of the standard locations: the HttpServletRequest, the HttpSession, or the ServletContext. Objects in these locations are known as “scoped variables,” and the expression language has a quick and easy way to access them.
You can also have scoped variables stored in the PageContext object, but this is much less useful because the servlet and the JSP page do not share PageContext objects. So, page-scoped variables apply only to objects stored earlier in the same JSP page, not to objects stored by a servlet. To output a scoped variable, you simply use its name in an expression language element.
For example, ${name} means to search the PageContext, HttpServletRequest, HttpSession, and ServletContext (in that order) for an attribute named. If the attribute is found, its toString method is called and that result is returned. If nothing is found, an empty string (not null or an error message) is returned.
So, for example, the following two expressions are equivalent. ${name} <%= pageContext.findAttribute("name") %>
http://pdf.coreservlets.com/JSP-EL.pdf
© Prentice Hall and Sun Microsystems Press. Personal use only
最新文章
- tabhost 下 setOnItemClickListener失效的问题
- iOS之处理不等高TableViewCell的几种方法
- Android UI控件----ExpandableListView的基本用法
- 写JQuery 插件 什么?你还不会写JQuery 插件
- 设置跨域的iframe的高度
- oracle 语句 字段拼接(可换行)
- 多线程基础(五)NSThread线程通信
- 开源软件授权协议详解(GPL/MPL/LGPL/BSD/Apache Licence/Creative Commons/MIT)
- 【Android 错误记录】installation error: INSTALL_PARSE_FAILED_NO_CERTIFICATES 错误
- 单元测试React
- Cocos2d-Java安装和配置跨平台游戏引擎以及相关的开发工具
- dreamweaver代码提示失效
- iOS 极光推送的集成以及一些集成后的狗血
- SQL优化 MySQL版 - B树索引详讲
- PHP开发者的路书
- verilog实现毫秒计时器
- Pg188-2 覆盖 向上转型
- apache 与 iis共存
- 自定义规则,对List<;Map<;String,Object>;>; List<;Object>;进行排序
- [Python] dict字典的浅复制与深复制