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
Accessing Scoped Variables的更多相关文章
- A brief introduction to per-cpu variables
墙外通道:http://thinkiii.blogspot.com/2014/05/a-brief-introduction-to-per-cpu.html per-cpu variables are ...
- C# 7 out variables, tuples & other new features
C# 7 out variables, tuples & other new features C# 7 is available on new Visual Studio 2017 and ...
- jsp 是什么 ,jsp 隐式对象
google 搜索 java server page http://www.oracle.com/technetwork/java/javaee/jsp/index.html http://docs. ...
- A JSTL primer, Part 2: Getting down to the core
In the initial article of this series, you got your first look at JSTL. We described the use of its ...
- lambada 表达式
1.lambada的存在来由 匿名类的一个问题是,如果匿名类的实现非常简单,例如只包含一个方法的接口,那么匿名类的语法可能看起来不实用且不清楚.在这些情况下,您通常会尝试将功能作为参数传递给另一个方法 ...
- Java Thread Local – How to use and code sample(转)
转载自:https://veerasundar.com/blog/2010/11/java-thread-local-how-to-use-and-code-sample/ Thread Local ...
- 【翻译十一】java-原子性操作
Atomic Access In programming, an atomic action is one that effectively happens all at once. An atomi ...
- Inversion of Control Containers and the Dependency Injection pattern(转)
In the Java community there's been a rush of lightweight containers that help to assemble components ...
- How to Use JUnit With JMeter
Do you need to use JUnit in your testing processes? To answer this question, let's take a look first ...
随机推荐
- select组件2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- [置顶] 第一天初试linux
1).unix linix macos android 的区别 Unix是要收费的,而linix是一种开源免费的unix ,macos 和andorid又是linux的一种,macos闭源,仅仅是 ...
- ReadWriteLock与ReentrantReadWriteLock
JAVA的JUC包中的锁包括"独占锁"和"共享锁".JUC中的共享锁有:CountDownLatch.CyclicBarrier.Semaphore.Reent ...
- ionic 安装教程
2015-10-08:国庆回来发现有新版本了,特意更新结果命令失效了,然后重新装吧,结果也失败多次 大概6-7次左右,然后系统是win10,可以启用管理员命令窗口进行安装,第二次成功了! 1.准备 ...
- Sql面试常考题(持续添加)
最近萌生换工作的念头,于是上网下载了一些公司的面试题,重新看了面试题中的Sql部分,这些查询题有时候只是兜一个弯角来考,对于给EF惯坏的孩子来说还是有点难度的(给面试官鄙视了几下的结果),所以列出最近 ...
- netMVC 搭建Ucenter 同步登陆退出discuz
先看一下效果
- ora01033 oracle正在初始化或关闭
toad连数据库报错: ORA-01033: ORACLE initialization or shutdown in progress 解决方法: 1)开始-运行-cmd 2)命令行中输入SQLPL ...
- BAT变量中的百分号学习
在BlogJava上看到如下的批处理文件,并将其转记在此: 1 2 3 4 5 6 7 8 @echo off rem bat 获取系统时间,并去掉时间小时前面的空格 rem 2012-12-12 ...
- 使用sqlldr命令导入资料到Oracle数据库表中的示例说明
CSV: Comma-Separated Values(逗号分隔值)的缩写,是以逗号分隔字段的多行文本文件 sqlldr 是sql*loader的缩写,此工具在安装完整版的Oracle客户端后就有 ...
- Mac OS X 配置环境变量
/etc/profile:/etc/bashrc 是针对系统所有用户的全局变量,只有root用户才能修改这两个文件,对一般用户来说是他们是只读的.一般用户要想修改它们,可以在命令前加sudo,意思是以 ...