| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 7373 人关注过本帖
标题:JSP technology
只看楼主 加入收藏
iloveenglish
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-5-7
收藏
 问题点数:0 回复次数:1 
JSP technology
This chapter describes the JSP configuration information, which is specified
in theWeb Application Deployment Descriptor in WEB-INF/web.xml. As of Servlet
2.4, the Web Application Deployment Descriptor is defined using XML Schema,
and imports the elements described in Section JSP.B.1, “XML Schema for JSP 2.0
Deployment Descriptor”. See that section for the details on how to specify JSP configuration
information in a Web Application.
JSP.3.1 JSP Configuration Information in web.xml
A Web Application can include general JSP configuration information in its
web.xml file that is to be used by the JSP container. The information is described
through the jsp-config element and its subelements.
The jsp-config element is a subelement of web-app that is used to provide
global configuration information for the JSP files in aWeb Application. A jsp-config
has two subelements: taglib and jsp-property-group, defining the taglib mapping
and groups of JSP files respectively.
JSP.3.2 Taglib Map
The web.xml file can include an explicit taglib map between URIs and TLD
resource paths described using taglib elements in the Web Application Deployment
descriptor.
The taglib element is a subelement of jsp-config that can be used to provide
information on a tag library that is used by a JSP page within the Web
Application. The taglib element has two subelements: taglib-uri and taglib-location.
JSP CONFIGURATION 1-86
JavaServer Pages 2.0 Specification
A taglib-uri element describes a URI identifying a tag library used in the web
application. The body of the taglib-uri element may be either an absolute URI
specification, or a relative URI as in Section JSP.1.2.1. There should be no
entries in web.xml with the same taglib-uri value.
A taglib-location element contains a resource location (as indicated in
Section JSP.1.2.1) of the Tag Library Description File for the tag library.
JSP.3.3 JSP Property Groups
A JSP property group is a collection of properties that apply to a set of files that
represent JSP pages. These properties are defined in one or more jsp-property-group
elements in the Web Application deployment descriptor.
Most properties defined in a JSP property group apply to an entire translation
unit, that is, the requested JSP file that is matched by its URL pattern and all the
files it includes via the include directive. The exception is the page-encoding
property, which applies separately to each JSP file matched by its URL pattern.
The applicability of a JSP property group is defined through one or more URL
patterns. URL patterns use the same syntax as defined in Chapter SRV.11 of the
Servlet 2.4 specification, but are bound at translation time. All the properties in
the group apply to the resources in the Web Application that match any of the
URL patterns. There is an implicit property: that of being a JSP file. JSP Property
Groups do not affect tag files.
If a resource matches a URL pattern in both a <servlet-mapping> and a <jspproperty-
group>, the pattern that is most specific applies (following the same rules
as in the Servlet specification). If the URL patterns are identical, the <jsp-propertygroup>
takes precedence over the <servlet-mapping>. If at least one <jsp-propertygroup>
contains the most specific matching URL pattern, the resource is
considered to be a JSP file, and the properties in that <jsp-property-group> apply.
In addition, if a resource is considered to be a JSP file, all include-prelude and
include-coda properties apply from all the <jsp-property-group> elements with
matching URL patterns (see Section JSP.3.3.5).
JSP.3.3.1 JSP Property Groups
A jsp-property-group is a subelement of jsp-config. The properties that can
currently be described in a jsp-property-group include:
JSP Property Groups 1-87
JavaServer Pages 2.0 Specification
? Indicate that a resource is a JSP file (implicit).
? Control disabling of EL evaluation.
? Control disabling of Scripting elements.
? Indicate page Encoding information.
? Prelude and Coda automatic includes.
? Indicate that a resource is a JSP document.
JSP.3.3.2 Deactivating EL Evaluation
Since the syntactic pattern ${expr} was not reserved in the JSP specifications
before JSP 2.0, there may be situations where such a pattern appears but the intention
is not to activate EL expression evaluation but rather to pass through the pattern
verbatim. To address this, the EL evaluation machinery can be deactivated as indicated
in this section.
Each JSP page has a default setting as to whether to ignore EL expressions.
When ignored, the expression is passed through verbatim. The default setting does
not apply to tag files, which always default to evaluating expressions.
The default mode for JSP pages in a Web Application delivered using a
web.xml using the Servlet 2.3 or earlier format is to ignore EL expressions; this
provides for backward compatibility.
The default mode for JSP pages in a Web Application delivered using a
web.xml using the Servlet 2.4 format is to evaluate EL expressions; this
automatically provides the default that most applications want.
The default mode can be explicitly changed by setting the value of the elignored
element. The el-ignored element is a subelement of jsp-property-group (see
Section JSP.3.3.1, “JSP Property Groups”). It has no subelements. Its valid values
are true and false.
For example, the following web.xml fragment defines a group that deactivates
EL evaluation for all JSP pages delivered using the .jsp extension:
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<el-ignored>true</el-ignored>
</jsp-property-group>
Page authors can override the default mode through the isELIgnored attribute
of the page directive. For tag files, there is no default, but the isELIgnored attribute
of the tag directive can be used to control the EL evaluation settings.
JSP CONFIGURATION 1-88
JavaServer Pages 2.0 Specification
Table JSP.3-1 summarizes the EL evaluation settings for JSP pages, and their
meanings:
Table JSP.3-2 summarizes the EL evaluation settings for tag files, and their
meanings:
The EL evaluation setting for a translation unit also affects whether the \$
quote sequence is enabled for template text and attribute values in a JSP page,
document, or tag file. When EL evaluation is disabled, \$ will not be recognized as
a quote, whereas when EL evaluation is enabled, \$ will be recognized as a quote
for $. See Section JSP.1.6, “Quoting and Escape Conventions” and
Section JSP.6.2.2, “Overview of Syntax of JSP Documents” for details.
Table JSP.3-1 EL Evaluation Settings for JSP Pages
JSP Configuration
<el-ignored>
Page Directive
isELIgnored EL Encountered
unspecified unspecified Ignored if <= 2.3 web.xml
Evaluated otherwise.
false unspecified Evaluated
true unspecified Ignored
don’t care false Evaluated
don’t care true Ignored
Table JSP.3-2 EL Evaluation Settings for Tag Files
Tag Directive
isELIgnored EL Encountered
unspecified Evaluated
false Evaluated
true Ignored
JSP Property Groups 1-89
JavaServer Pages 2.0 Specification
JSP.3.3.3 Disabling Scripting Elements
With the addition of the EL, some JSP page authors, or page authoring groups,
may want to follow a methodology where scripting elements are not allowed. Previous
versions of JSP enabled this through the notion of a TagLibraryValidator that
would verify that the elements are not present. JSP 2.0 makes this slightly easier
through a JSP configuration element.
The scripting-invalid element is a subelement of jsp-property-group (see 3.3.1).
It has no subelements. Its valid values are true and false. Scripting is enabled by
default. Disabling scripting elements can be done by setting the scripting-invalid
element to true in the JSP configuration.
For example, the following web.xml fragment defines a group that disables
scripting elements for all JSP pages delivered using the .jsp extension:
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<scripting-invalid>true</scripting-invalid>
</jsp-property-group>
Table JSP.3-3 summarizes the scripting settings and their meanings:
JSP.3.3.4 Declaring Page Encodings
The JSP configuration element page-encoding can be used to easily set the
pageEncoding property of a group of JSP pages defined using the jsp-propertygroup
element. This is only needed for pages in standard syntax, since for
documents in XML syntax the page encoding is determined as described in
section 4.3.3 and appendix F.1 of the XML specification.
The page-encoding element is a subelement of jsp-property-group (see 3.3.1).
It has no subelements. Its valid values are those of the pageEncoding page
Table JSP.3-3 Scripting Settings
JSP Configuration
<scripting-invalid> Scripting Encountered
unspecified Valid
false Valid
true Translation Error
JSP CONFIGURATION 1-90
JavaServer Pages 2.0 Specification
directive. It is a translation-time error to name different encodings in the pageEncoding
attribute of the page directive of a JSP page and in a JSP configuration
element matching the page. It is also a translation-time error to name different
encodings in the prolog / text declaration of the document in XML syntax and in a
JSP configuration element matching the document. It is legal to name the same
encoding through multiple mechanisms.
For example, the following web.xml fragment defines a group that explicitly
assigns Shift_JIS to all JSP pages and included JSP segments in the /ja
subdirectory of the web application:
<jsp-property-group>
<url-pattern>/ja/*</url-pattern>
<page-encoding>Shift_JIS</page-encoding>
</jsp-property-group>
JSP.3.3.5 Defining Implicit Includes
The include-prelude element is an optional subelement of jsp-property-group.
It has no subelements. Its value is a context-relative path that must correspond to
an element in the Web Application. When the element is present, the given path
will be automatically included (as in an include directive) at the beginning of the
JSP page in the jsp-property-group. When there are more than one include-prelude
element in a group, they are to be included in the order they appear. When more
than one jsp-property-group applies to a JSP page, the corresponding includeprelude
elements will be processed in the same order as they appear in the JSP
configuration section of web.xml.
The include-coda element is an optional subelement of jsp-property-group. It
has no subelements. Its value is a context-relative path that must correspond to an
element in the Web Application. When the element is present, the given path will
be automatically included (as in an include directive) at the end of the JSP page in
the jsp-property-group. When there are more than one include-coda element in a
group, they are to be included in the order they appear. When more than one jspproperty-
group applies to a JSP page, the corresponding include-coda elements
will be processed in the same order as they appear in the JSP configuration section
of web.xml. Note that these semantics are in contrast to the way url-patterns are
matched for other configuration elements.
Preludes and codas follow the same rules as statically included JSP segments.
In particular, start tags and end tags must appear in the same file (see
Section JSP.1.3.3).
JSP Property Groups 1-91
JavaServer Pages 2.0 Specification
For example, the following web.xml fragment defines two groups. Together
they indicate that everything in directory /two/ have /WEB-INF/jspf/prelude1.jspf
and /WEB-INF/jspf/prelude2.jspf at the beginning and /WEB-INF/jspf/coda1.jspf and
/WEB-INF/jspf/coda2.jspf at the end, in that order, while other .jsp files only have
/WEB-INF/jspf/prelude1.jspf at the beginning and /WEB-INF/jspf/coda1.jspf at the
end.
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<include-prelude>/WEB-INF/jspf/prelude1.jspf</include-prelude>
<include-coda>/WEB-INF/jspf/coda1.jspf</include-coda>
</jsp-property-group>
<jsp-property-group>
<url-pattern>/two/*</url-pattern>
<include-prelude>/WEB-INF/jspf/prelude2.jspf</include-prelude>
<include-coda>/WEB-INF/jspf/coda2.jspf</include-coda>
</jsp-property-group>
JSP.3.3.6 Denoting XML Documents
The JSP configuration element is-xml can be used to denote that a group of
files are JSP documents, and thus must be interpreted as XML documents.
The is-xml element is a subelement of jsp-property-group (see 3.3.1). It has no
subelements. Its valid values are true and false. When false, the files in the
associated property group are assumed to not be JSP documents, unless there is
another property group that indicates otherwise. The files are still considered to be
JSP pages due to the implicit property given by the <jsp-property-group> element.
For example, the following web.xml fragment defines two groups. The first
one indicates that those files with extension .jspx, which is the default extension
for JSP documents, are instead just plain JSP pages. The last group indicates that
files with extension .svg are actually JSP documents (which most likely are
generating SVG files).
<jsp-property-group>
<url-pattern>*.jspx</url-pattern>
<is-xml>false</is-xml>
</jsp-property-group>
JSP CONFIGURATION 1-92
JavaServer Pages 2.0 Specification
<jsp-property-group>
<url-pattern>*.svg</url-pattern>
<is-xml>true</is-xml>
</jsp-property-group>
搜索更多相关主题的帖子: technology JSP 
2008-05-07 19:13
wu2leng
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-12
收藏
得分:0 
那位大哥能把这篇文章给翻译成中文啊!!
急!!!急!!!
2008-06-12 01:15
快速回复:JSP technology
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017733 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved