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. android应用版本更新功能---完整版

    源码下载地址:csdn下载地址:http://download.csdn.net/download/csdn576038874/9526085 博客园下载地址:http://files.cnblogs ...

  2. 初识hibernate

    //针对myEclipse2014版本 怎样新建一个工程实现这些东西的导入. 打开myeclipse. 2.点击右上角的open perspective 找到这个 MyEclipse Database ...

  3. [转]Form Builder:app_field.clear_dependent_fields和APP_FIELD.set_dependent_field的用法

    转自:http://www.cnblogs.com/toowang/p/3668070.html 可以调用APP_FIELD.clear_dependent_fields和APP_FIELD.set_ ...

  4. 11.13 noip模拟试题

    题目名称 笔记 括号 城堡可执行文件名 note brackets castle输入文件名 note.in brackets.in castle.in输出文件名 note.in brackets.ou ...

  5. jQuery 定时局部刷新(setInterval)方法总结

    来自:http://www.jbxue.com/article/8516.html 1.jQuery 定时局部刷新(setInterval),显示时间的代码. <head> <scr ...

  6. 读《编写高质量代码:改善JavaScript程序的188个建议》1

    建议3:减少全局变量污染 定义全局变量有3种方式: ❑在任何函数外面直接执行var语句. var f='value'; ❑直接添加一个属性到全局对象上.全局对象是所有全局变量的容器.在Web浏览器中, ...

  7. Java Mybatis 传参方式

    一.单个参数: public List<XXBean> getXXBeanList(String xxCode); <select id="getXXXBeanList&q ...

  8. 实现View弹性滑动例子

    弹性滑动原理 将一次大的滑动非为若干次小的滑动,并在一个时间段内完成.有一种顺畅的感觉更-好的用户体验 实现方式很多种,包括用Scroller.动画.延时策略. 使用Handler实现弹性滑动 效果可 ...

  9. JavaSE生成随机数

    今天呢,老师讲了一下怎么用jvm实现随机数(本人对此很感兴趣),一个简单的随机100以内整数的代码如下: /** 生成随机数 */ import java.util.Random; public cl ...

  10. swift入门-day02

    1.函数 2.闭包 3.构造函数基础 4.重载构造函数 5.KVC构造函数 6.遍历构造函数 7.懒加载 8.只读属性 1.函数 掌握函数的定义 掌握外部参数的用处 掌握无返回类型的三种函数定义方式 ...