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 ...
随机推荐
- SpannableString使用详解
TextView算是android开发中最最常用的控件了,有的时候,我们要给一个TextView中的显示的文字设置不同的样式或者响应事件,比如同一个TextView中,有的字是红色,有的字是蓝色,有的 ...
- base查找方法的实现JAVA
import java.util.List; import java.util.ArrayList; import java.util.Scanner; /*在一个有序数组中查找一个数的过程,模拟二分 ...
- Android Activiy的作用
在Android应用程序中 ,Activity主要的负责创建窗口的,一个Activicy就是代表一个单独的屏幕,并且是用户唯一可以看到的东西 也就是说Activity就是用来实现和用户交互的,就和.n ...
- mysql数据库时间、字符串类型互转
时间格式转换: select DATE_FORMAT(NOW(),"%y-%m-%d %H:%i:%s") 字符串转时间: select STR_TO_DATE("201 ...
- 爬虫神器XPath,程序员带你免费获取周星驰等明星热门电影
本教程由"做全栈攻城狮"原创首发,本人大学生一枚平时还需要上课,但尽量每日更新文章教程.一方面把我所习得的知识分享出来,希望能对初学者有所帮助.另一方面总结自己所学,以备以后查看. ...
- SWFObject2.0
PROBLEM: using % in the height and width(e.g. 100%) with the SWFObject 2.0 (or 2.1) with dynamic pub ...
- linux下apache-tomcat的安装
一.JDK安装 1.安装JDK软件包 本例使用的JDK安装包为jdk-6u19-linux-x64.bin,该包是一个编译好的二进制可执行程序包,只需要执行即可安装. 首先进入存放JDK安装包的目录( ...
- MyBatis3.1 学习教程
昨天中午,突然有想要学习 MyBatis 的冲动,经过 1.5 天的研究和学习,再加上以前学过 I batis 的经验,很快就了解了这门技术. 写这篇教程,是想告诉那些想学却又怕学习不好的同学们, 其 ...
- HTTP协议认识
一.HTTP协议概念 HTTP协议(HyperText Transfer Protocol,超文本传输协议)是用于从WWW服务器传输超文本到本地浏览器的传送协议 HTTP是一个应用层协议,由请求和响应 ...
- JavaScript学习笔记 -- ES6学习(三) 变量的解构赋值
1.解构赋值的定义 在ES6中,允许按照一定模式,从数组和对象中提取值(所谓解构),然后对变量进行赋值. var a = 1; var b = 2; var c = 3; //等价于 var [a, ...