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的更多相关文章

  1. A brief introduction to per-cpu variables

    墙外通道:http://thinkiii.blogspot.com/2014/05/a-brief-introduction-to-per-cpu.html per-cpu variables are ...

  2. 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 ...

  3. jsp 是什么 ,jsp 隐式对象

    google 搜索 java server page http://www.oracle.com/technetwork/java/javaee/jsp/index.html http://docs. ...

  4. 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  ...

  5. lambada 表达式

    1.lambada的存在来由 匿名类的一个问题是,如果匿名类的实现非常简单,例如只包含一个方法的接口,那么匿名类的语法可能看起来不实用且不清楚.在这些情况下,您通常会尝试将功能作为参数传递给另一个方法 ...

  6. 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 ...

  7. 【翻译十一】java-原子性操作

    Atomic Access In programming, an atomic action is one that effectively happens all at once. An atomi ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. windows 下 node 多版本管理工具 - gnvm

    最近写了各个构建工具, 开发环境为mac,需要在windows下测试通过: 因为很久不用windows,windows下的node 版本还是 0.10.* 的,因此决定升级node mac 下我使用的 ...

  2. asp.net 网站发布的步骤

    网站发布步骤: 这部分是转载文章 在此标明出处,以前有文章是转的没标明的请谅解,因为有些已经无法找到出处,或者与其它原因. 如有冒犯请联系本人,或删除,或标明出处. 因为好的文章,以前只想收藏,但连接 ...

  3. c++基础语法 构造函数 析构函数 类的组合

    1 构造函数 1.不能指定任何返回值,甚至连void都不能有. 2.与Java不同,c++不同new对象,对于无参的构造函数声明对象时括号应该省略. 2 析构函数 1. 前加~,不能有参数,不能有返回 ...

  4. 解决PL/SQL Developer中文乱码的问题

    set nls_lang=SIMPLIFIED CHINESE_CHINA.ZHS16GBK cd "c:\Program Files\PLSQL Developer" PLSQL ...

  5. 使用DOM4J解析XMl文件与读取XML文件

    XML文件 <?xml version="1.0" encoding="UTF-8"?> <bookstore> <book id ...

  6. C#微信公众号开发 -- (五)自定义菜单创建

    公众号中,底部都是有自己定义的功能按钮,通过点击某个按钮来实现指定的业务逻辑操作. 下面就来说说这些按钮是怎样放到微信公众平台的,还是先来看看微信的官方解释: 请注意: 1.自定义菜单最多包括3个一级 ...

  7. (转)C#中的Dictionary字典类介绍

    关键字:C# Dictionary 字典 作者:txw1958原文:http://www.cnblogs.com/txw1958/archive/2012/11/07/csharp-dictionar ...

  8. WPF窗体视图中绑定Resources文件中字符串时,抛出:System.Windows.Markup.StaticExtension

    问题描述: 在Resources.resx定义了一个静态字符串字段Title,并在WPF窗体视图中绑定为窗体的标题: Title="{x:Static local:Resources.Tit ...

  9. onMouseDown onMouseUp onMouseMove(移动鼠标图像大小变化)

  10. 【CODECHEF】【phollard rho + miller_rabin】The First Cube

    All submissions for this problem are available. Read problems statements in Mandarin Chinese and Rus ...