内置对象相关文档:
http://docs.oracle.com/javaee/5/tutorial/doc/bnahq.html#bnaij(Java EE 1.5)
http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html#wp71043(Java EE 1.4)
Implicit Objects
The JSP expression language defines a set of implicit objects:
-
pageContext: The context for the JSP page. Provides access to various objects including:
-
In addition, several implicit objects are available that allow easy access to the following objects:
-
param: Maps a request parameter name to a single value
-
paramValues: Maps a request parameter name to an array of values
-
header: Maps a request header name to a single value
-
headerValues: Maps a request header name to an array of values
-
cookie: Maps a cookie name to a single cookie
-
initParam: Maps a context initialization parameter name to a single value
-
Finally, there are objects that allow access to the various scoped variables described inUsing
Scope Objects.
-
pageScope: Maps page-scoped variable names to their values
-
requestScope: Maps request-scoped variable names to their values
-
sessionScope: Maps session-scoped variable names to their values
-
applicationScope: Maps application-scoped variable names to their values
JSP 2.1 provides two EL resolvers to handle expressions that reference these objects:ImplicitObjectELResolverandScopedAttributeELResolver.
A variable that matches one of the implicit objects is evaluated byImplicitObjectResolver, which returns the implicit object. This resolver only handles expressions with a base ofnull.
What this means for the following expression is that theImplicitObjectResolverresolves thesessionScopeimplicit object only. Once the implicit
object is found, theMapELResolverinstance resolves theprofileattribute because theprofileobject
represents a map.
${sessionScope.profile}
ScopedAttributeELResolverevaluates a single object that is stored in scope. LikeImplicitObjectELResolver, it also only evaluates expressions
with a base ofnull. This resolver essentially looks for an object in all of the scopes until it finds it, according to the behavior ofPageContext.findAttribute(String).
For example, when evaluating the expression${product}, the resolver will look forproductin the page, request, session, and application scopes
and will return its value. Ifproductis not found,nullis returned.
When an expression references one of the implicit objects by name, the appropriate object is returned instead of the corresponding attribute. For example,${pageContext}returns thePageContextobject,
even if there is an existingpageContextattribute containing some other value.
其他相关文档
http://jcp.org/aboutJava/communityprocess/final/jsr245/index.html (Java Server Pages 2.1)
http://jcp.org/en/jsr/detail?id=341(EL 3.0)
http://docs.oracle.com/javaee/7/api/javax/el/package-summary.html(JavaEE 7 EL3.0类文档)
http://docs.oracle.com/javaee/7/tutorial/doc/jsf-el.htm(Java EE 7教程 EL表达式)
http://docs.oracle.com/javaee/5/tutorial/doc/bnahl.html#bnaho(Java EE 5 Tutorial JSP中的对象)
JSP内置对象:
Creating Dynamic Content
You create dynamic content by accessing Java programming language object properties.
Using Objects within JSP Pages
You can access a variety of objects, including enterprise beans and JavaBeans components, within a JSP page. JSP technology automatically makes some objects available, and you can also create and access application-specific objects.
Using Implicit Objects
Implicit objects are created by the web container and contain information related to a particular request, page, session, or application. Many of the objects are defined by the
Java servlet technology underlying JSP technology and are discussed at length in
Chapter4, Java Servlet Technology. The section
Implicit Objects explains how you access implicit objects using the JSP expression language.
Using Application-Specific Objects
When possible, application behavior should be encapsulated in objects so that page designers can focus on presentation issues. Objects can be created by developers who are proficient in the Java
programming language and in accessing databases and other services. The main way to create and use application-specific objects within a JSP page is to use JSP standard tags (discussed inJavaBeans
Components) to create JavaBeans components and set their properties, and EL expressions to access their properties. You can also access JavaBeans components and other objects in scripting elements, which are described inChapter9,
Scripting in JSP Pages.
Using Shared Objects
The conditions affecting concurrent access to shared objects (described inControlling Concurrent
Access to Shared Resources) apply to objects accessed from JSP pages that run as multithreaded servlets. You can use the followingpage directive to indicate how a web container should dispatch multiple client requests:
<%@ page isThreadSafe="true|false" %>
When the isThreadSafe attribute is set totrue, the web container can choose to dispatch multiple concurrent client requests to the JSP page. This is thedefault
setting. If using true, you must ensure that you properly synchronize access to any shared objects defined at the page level. This includes objects created within declarations, JavaBeans components with page scope, and attributes of the page context
object (see
Implicit Objects).
If isThreadSafe is set to false, requests are dispatched one at a time in the order they were received, and access to page-level objects does not have to be controlled. However, you still must ensure that access is properly synchronized
to attributes of the application or session scope objects and to JavaBeans components with application or session scope. Furthermore, it is not recommended to setisThreadSafe to
false. The JSP page’s generated servlet will implement thejavax.servlet.SingleThreadModel interface, and because the Servlet 2.4 specification deprecatesSingleThreadModel, the generated servlet will contain deprecated code.
版权声明:本文为博主原创文章,未经博主允许不得转载。
分享到:
相关推荐
EL表达式总结概括,请下载EL表达式总结概括
JAVAEE实验报告EL表达式和jstl标签库的使用.pdf
8.1 理解表达式语言 8.2 使用EL运算符 8.3 使用EL访问数据 8.4 在EL中使用函数 8.5 在JSP页面中禁用EL 8.6 小 结
本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目的难度比较适中,内容都是经过助教老师审定过的,应该能够满足学习、使用需求,如果有需要的话可以放心下载使用。...
JavaEE基础JSP的9个内置对象.1,out: 2,request: 3,response: 4,session: 5,pageContext: 6,application: 7,config: 8,page: 9,exception:
JavaEE+JDBC+Servlet+EL表达式的员工信息管理系统 本资源中的源码都是经过本地编译过可运行的,下载后按照文档配置好环境就可以运行。资源项目源码系统完整,内容都是经过专业老师审定过的,基本能够满足学习、使用...
JavaEE+JDBC+Servlet+EL表达式的员工信息管理系统源码+数据库+项目说明(高分课设).zip # :heart: JavaEE+JDBC+Servlet+EL表达式的员工信息管理系统 ## 介绍 简易的员工管理系统,包括信息的增删改查,新增员工...
WEB18_el&jstl。完成商品的列表的展示。...3.EL的内置对象11个 4.EL执行表达式 1.JSTL概述 2.JSTL下载与导入 3.JSTL核心库的常用标签 1.什么是模式 2.javaEE经历的模式 3.javaEE的三层架构
在自己练手时遇到了EL表达式被当成字符串处理而没有正确解析的现象。当时工程中使用的Javaee5, web.xml xmlns javaee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation> EL表达式死活不...
JavaEE应用开发教程课件08EL和JSTL.pdfJavaEE应用开发教程课件08EL和JSTL.pdfJavaEE应用开发教程课件08EL和JSTL.pdfJavaEE应用开发教程课件08EL和JSTL.pdfJavaEE应用开发教程课件08EL和JSTL.pdfJavaEE应用开发教程...
JavaEE 系统架构 持久化层 面向对象 工作流
EL 提供.和[]两种运算符来存取数据。当要存取的属性名称中包含一些特殊字符,如.或?等并非字母或数字的符号,就一定要使用 []。JSTL主要提供了5大类标签库:核心标签库、 国际化(I18N)标签库、SQL标签库、XML标签库、...