Oracle® Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference
10g Release 2 (10.1.2) B14016-02 |
|
Previous |
Next |
This manual documents tag libraries, JavaBeans, and other utilities supplied with Oracle Application Server Containers for J2EE (OC4J) that are implemented according to JSP standards. There is also a discussion of support for the JavaServer Pages Standard Tag Library (JSTL), and a section summarizing tag libraries provided with Oracle components outside of OC4J.
Oracle-specific features, as well as an introduction to the OC4J JSP container, standard JSP technology, and standard JSP 1.2 tag library features, are covered in the Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide.
This chapter consists of the following sections:
Tags and JavaBeans introduced in the first section provide functionality in several different areas, including type extensions, integration with XML/XSL, database access, and programming convenience.
Note: The Sample Applications chapter available in previous releases has been removed. Applications that were listed there are available in the OC4J demos, available from the following location on the Oracle Technology Network (requiring an OTN membership, which is free of charge):
|
The Oracle extensions that are introduced in the following sections are implemented through tag libraries or custom JavaBeans that comply with JSP and JavaBeans standards.
Be aware that some custom tag libraries provided with OC4J—XML, data-access, and JML—pre-date the JavaServer Pages Standard Tag Library (JSTL) and have areas of duplicate functionality. For standards compliance, it is now generally advisable to use JSTL instead of these custom libraries. See "Support for the JavaServer Pages Standard Tag Library".
Oracle is not desupporting the existing libraries, however. For features in the custom library that are not yet available in JSTL, where there seems to be general usefulness, Oracle will try to have the features adopted into the JSTL standard as appropriate.
Notes:
|
For the syntax documentation in tag descriptions throughout this manual, note the following:
Italic indicates that you must specify a value or string.
Optional attributes are enclosed in square brackets: [...]
Default values of optional attributes are indicated in bold.
Choices in attribute values are separated by vertical bars: |
Except where noted, you can use JSP runtime expressions to set tag attribute values: "<%=
jspExpression %>"
Tag descriptions in this manual use certain tag prefixes by convention; however, you can designate any desired prefix in your taglib
directives.
JSP pages generally rely on core Java types in representing scalar values. However, neither of the following standard type categories is fully suitable for use in JSP pages:
Primitive types such as int
, float
, and double
Values of these types cannot have a specified scope. They cannot be stored in a JSP scope object (for page
, request
, session
, or application
scope), because only objects can be stored in a scope object.
Wrapper classes in the standard java.lang
package, such as Integer
, Float
, and Double
Values of these types are objects, so they can theoretically be stored in a JSP scope object. However, they cannot be declared in a jsp:useBean
action, because the wrapper classes do not follow the JavaBean model and do not provide zero-argument constructors.
Additionally, instances of the wrapper classes are immutable. To change a value, you must create a new instance and assign it appropriately.
To work around these limitations in a JDK 1.4 or earlier environment, OC4J provides the JmlBoolean
, JmlNumber
, JmlFPNumber
, and JmlString
JavaBean classes in package oracle.jsp.jml
to wrap the most common Java types.
For information, see Chapter 2, "JavaBeans for Extended Types".
Important: JspScopeListener is deprecated in the OC4J 10.1.2 implementation and will be desupported in later implementations.
|
OC4J provides the JspScopeListener
interface for lifecycle management of Java objects of various scopes within a JSP application.
Standard servlet and JSP event-handling is provided through the javax.servlet.http.HttpSessionBindingListener
interface, but this is for session-based events only. The Oracle JspScopeListener
can be integrated with HttpSessionBindingListener
to manage session-based events, and can handle page-based, request-based, and application-based events as well.
For information, see "JSP Event-Handling with JspScopeListener".
You can use JSP syntax to generate any text-based MIME type, not just HTML code. In particular, you can dynamically create XML output. When you use JSP pages to generate an XML document, however, you often want a stylesheet applied to the XML data before it is sent to the client. This is difficult in JavaServer Pages technology, because the standard output stream used for a JSP page is written directly back through the server.
OC4J provides special tags to specify that all or part of a JSP page should be transformed through an XSL stylesheet before it is output. Input can be from the tag body or from an XML DOM object, and output can be to an XML DOM object to the browser.
You can use these tags multiple times in a single JSP page if you want to specify different style sheets for different portions of the page.
There is additional XML support as well:
A utility tag converts data from an input stream to an XML DOM object.
Several tags, for such features as caching and SQL operations, now can take XML objects as input or send them as output.
XML utility tags are summarized in Table 1-1. Note that there is also XML functionality in the dbOpen
SQL tag and the cacheXMLObj
Web Object Cache tag. For more information, see Chapter 5, "XML and XSL Tag Support".
You can find information about standard JSP 1.2 XML support in the Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide.
Table 1-1 Summary of XML Utility Tags
Tag | Description | Attributes |
---|---|---|
transform |
Output XML data with an XSL transformation, either to an HTTP client or a specified XML DOM object. |
href, fromXMLObjName, toXMLObjName, toWriter |
styleSheet |
Same as |
href, fromXMLObjName, toXMLObjName, toWriter |
parsexml |
Convert from an input stream to an XML DOM object. |
resource, toXMLObjName, validateResource, root |
OC4J supplies a set of custom JavaBeans for use in accessing Oracle Database. The following beans are provided in the oracle.jsp.dbutil
package:
ConnBean
opens a database connection. This bean also supports data sources and connection pooling.
ConnCacheBean
uses the Oracle connection caching implementation for database connections. (This requires JDBC 2.0.)
DBBean
executes a database query.
CursorBean
provides general DML support for queries; UPDATE
, INSERT
, and DELETE
statements; and stored procedure calls.
For information, see "JavaBeans for Data Access".
For JSP programmers, OC4J also provides a custom tag library for SQL functionality, wrapping the functionality of the JavaBeans. These tags are summarized in Table 1-2. For further information, see "SQL Tags for Data Access".
Table 1-2 Summary of Data-Access Tag Library
Tag | Description | Attributes |
---|---|---|
dbOpen |
Open a database connection. This tag also supports data sources and connection pooling. |
connId, scope, dataSource, user, password, URL, commitOnClose, |
dbClose |
Close a database connection. |
connId, scope |
dbQuery |
Execute a query. |
queryId, connId, scope, output, maxRows, skipRows, bindParams, toXMLObjName |
dbCloseQuery |
Close the cursor for a query. |
queryId |
dbNextRow |
Process the rows of a result set. |
queryId |
dbExecute |
Execute any SQL statement (DML or DDL). |
connId, scope, output, bindParams |
dbSetParam |
Set a parameter to bind into a |
name, value, scope |
dbSetCookie |
Set a cookie. |
name, value, domain, comment, maxAge, version, secure, path |
Important: The JML tag library is deprecated in the OC4J 10.1.2 implementation, and will be desupported in later implementations. Use the standard JSTL tag library instead. |
Although the JSP specification supports scripting languages other than Java, Java is the primary language used. Even though JavaServer Pages technology is designed to separate the dynamic/Java development effort from the static/HTML development effort, it is a hindrance if the Web developer does not know any Java, especially in small development groups where no Java experts are available.
OC4J provides custom tags as an alternative: the JSP Markup Language (JML). The Oracle JML tag library provides an additional set of JSP tags so that you can script your JSP pages without using Java statements. JML provides tags for variable declarations, control flow, conditional branches, iterative loops, parameter settings, and calls to objects. The JML tag library also supports XML functionality, as noted previously.
The following example shows use of the JML for
tag, repeatedly printing "Hello World" in progressively smaller headings (H1, H2, H3, H4, H5):
<jml:for id="i" from="<%= 1 %>" to="<%= 5 %>" > <H<%=i%>> Hello World! </H<%=i%>> </jml:for>
The JML tag library is summarized in Table 1-3. For more information, see Chapter 3, "JSP Markup Language Tags".
Table 1-3 Summary of JSP Markup Language Tag Library
Tag | Description | Attributes |
---|---|---|
useVariable |
This tag offers a convenient alternative to the |
id, scope, type, value |
useForm |
This tag provides a convenient syntax for declaring variables and setting them to values passed in from the request. |
id, scope, type, param |
useCookie |
This tag offers a convenient syntax for declaring variables and setting them to values contained in cookies. |
id, scope, type, cookie |
remove |
This tag removes an object from its scope. |
id, scope |
if |
This tag evaluates a single conditional statement. If the condition is true, then the body of the |
condition |
choose |
The |
(None) |
when |
This is used with the |
condition |
otherwise |
This is optionally used with the |
(None) |
for |
This tag provides the ability to iterate through a loop, as with a Java |
id, from, to |
foreach |
This tag provides the ability to iterate over a homogeneous set of values in a Java array, |
id, in, limit, type |
return |
When this tag is reached, execution returns from the page without further processing. |
(None) |
flush |
This tag writes the current contents of the page buffer back to the client. This applies only if the page is buffered; otherwise, there is no effect. |
(None) |
Note: Oracle JSP container versions preceding the JSP 1.1 specification use an Oracle-specific compile-time implementation of the JML tag library. Oracle still supports this implementation as an alternative to the standard runtime implementation, as documented in Appendix A, "JML Compile-Time Syntax and Tags". |
Web site personalization is a mechanism to tailor recommendations to users of a site, based on behavioral and demographic data. Recommendations are made in real-time, during a user's Web session. User behavior is saved to a database repository for use in building models for predictions of future user behavior.
OracleAS Personalization uses data mining algorithms in Oracle Database to choose the most relevant content available for a user. Recommendations are calculated by an OracleAS Personalization recommendation engine, using typically large amounts of data regarding past and current user behavior. This is superior to other approaches that rely on common-sense heuristics and require manual definition of rules in the system.
The OracleAS Personalization tag library brings this functionality to a wide audience of JSP developers for use in HTML, XML, or JavaScript pages. The tag interface is layered on top of the Java API of the recommendation engine.
Table 1-4 summarizes the OracleAS Personalization tag library. See Chapter 10, "Personalization Tags" for information.
Table 1-4 Summary of OracleAS Personalization Tag Library
Tag | Description | Attributes |
---|---|---|
startRESession |
Start an OracleAS Personalization recommendation engine session. |
REName, REURL, RESchema, REPassword, RECacheSize, REFlushInterval, applicationSession, createSession, userType, userID, storeUserIDIn, disableRecording |
endRESession |
Explicitly end a recommendation engine session. |
(None) |
setVisitorToCustomer |
Use this tag for situations where an anonymous visitor creates a registered customer account. |
customerID |
getRecommendations |
Request a set of recommendations for purchasing, navigation, or ratings. |
from, fromHotPicksGroups, storeResultsIn, storeInterestDimensionIn, maxQuantity, tuningName, tuningDataSource, tuningInterestDimension, tuningPersonalizationIndex, tuningProfileDataBalance, tuningProfileUsage, filteringName, filteringTaxonomyID, filteringMethod, filteringCategories, sortOrder |
getCrossSellRecommendations |
Request a set of recommendations for purchasing, navigation, or ratings, based on input of a set of past items (such as past purchases) that are used as a basis for the recommendations. |
storeResultsIn, storeInterestDimensionIn, fromHotPicksGroups, inputItemList, maxQuantity, tuningName, tuningDataSource, tuningInterestDimension, tuningPersonalizationIndex, tuningProfileDataBalance, tuningProfileUsage, filteringName, filteringTaxonomyID, filteringMethod, filteringCategories, sortOrder |
selectFromHotPicks |
Request recommendations from a set of "hot picks" groups only. |
hotPicksGroups, storeResultsIn, storeInterestDimensionIn, maxQuantity, tuningName, tuningDataSource, tuningInterestDimension, tuningPersonalizationIndex, tuningProfileDataBalance, tuningProfileUsage, filteringName, filteringTaxonomyID, filteringMethod, filteringCategories, sortOrder |
evaluateItems |
Evaluate only the set of items that are input to the tag. |
storeResultsIn, taxonomyID, inputItemList, tuningName, tuningDataSource, tuningInterestDimension, tuningPersonalizationIndex, tuningProfileDataBalance, tuningProfileUsage, sortOrder |
forItem |
Select individual items input to a tag that requires an input list. |
index, itemList, type, ID |
getNextItem |
Optionally use this tag within some recommendation tags to access and process returned items. |
storeTypeIn, storeIDIn, storeItemIn |
recordNavigation |
Record a navigation item into the recommendation engine session cache. |
type, ID, index, itemList |
recordPurchase |
Record a purchasing item into the recommendation engine session cache. |
type, ID, index, itemList |
recordRating |
Record a rating item into the recommendation engine session cache. |
value, type, ID, index, itemList |
recordDemographic |
Record a demographic item into the recommendation engine session cache. |
type, value |
removeNavigationRecord |
Remove a navigation item that had been recorded into the recommendation engine session cache earlier in the session. |
type, ID, index, itemList |
removePurchaseRecord |
Remove a purchasing item that had been recorded into the recommendation engine session cache earlier in the session. |
type, ID, index, itemList |
removeRatingRecord |
Remove a rating item that had been recorded into the recommendation engine session cache earlier in the session. |
value, type, ID, index, itemList |
removeDemographicRecord |
Remove a demographic item that had been recorded into the recommendation engine session cache earlier in the session. |
type, value |
The Web services tag library provided with OC4J enables developers to conveniently create JSP pages for Web service client applications. The implementation uses a SOAP-based mechanism, supporting RPC-style or document-style services. A client application would access a Web Services Description Language (WSDL) document, then use the WSDL information to access the operations of a Web service.
The tag library also uses the Oracle implementation of the dynamic invocation API, described in the Oracle Application Server Web Services Developer's Guide. When a client application acquires a WSDL document at runtime, the dynamic invocation API is the vehicle for invoking any SOAP operation described in the WSDL document.
The Web services tag library is summarized in Table 1-5. For more information, see Chapter 11, "Web Services Tags".
Table 1-5 Summary of Web Services Tag Library
Tag | Description | Attributes |
---|---|---|
webservice |
Create a Web service proxy. The tag requires the URL of a WSDL document and uses either a binding and SOAP location or a service name and port in creating the proxy. |
wsdlUrl, id, scope, binding, soapLocation, service, port |
map |
Use |
localName, namespaceUri, javaType, encodingStyle, java2xmlClassName, xml2javaClassName |
property |
Optionally use this tag to specify a name/value pair that defines any of several supported custom properties for use by the Web service client application. |
name, value |
invoke |
Invoke an operation of a Web service. The |
id, operation, webservice, inputMsgName, outputMsgName, xmlToWriter, toXMLObjName |
part |
Use this tag if the operation being performed requires input message part values, using one part tag for each input part. |
name, value |
OC4J provides tag libraries for file access (uploading and downloading) and for sending e-mail messages from an application.
For uploading files, you can use the httpUpload
tag or the oracle.jsp.webutil.fileaccess.HttpUploadBean
JavaBean. For downloading, there is the httpDownload
tag or the HttpDownloadBean
JavaBean. Table 1-6 summarizes the file access tags. For more information, see "File-Access JavaBeans and Tags".
Table 1-6 Summary of File Access Tag Library
Tag | Description | Attributes |
---|---|---|
httpUploadForm |
For convenience, you can use this tag to create a form in your application, using multipart encoded form data, that allows users to specify the files to upload. |
formsAction, maxFiles, fileNameSize, maxFileNameSize, includeNumbers, submitButtonText |
httpUpload |
Upload files from the client to a server. You can upload into either a file system or a database. |
destination, destinationType, connId, scope, overwrite, fileType, table, prefixColumn, fileNameColumn, dataColumn |
httpDownload |
Download files from a server to the client. You can download from either a file system or a database. |
servletPath, source, sourceType, connId, scope, recurse, fileType, table, prefixColumn, fileNameColumn, dataColumn |
For sending e-mail messages, optionally with server-side or client-side attachments, you can use the oracle.jsp.webutil.email.SendMailBean
JavaBean or the sendMail
tag. Table 1-7 summarizes the sendMail
tag. See "Mail JavaBean and Tag" for more information.
OC4J provides a custom tag library to simplify the use of Enterprise JavaBeans in JSP pages. The functionality of the OC4J EJB tags follows the J2EE specification. The tags allow you to instantiate EJBs by name, using configuration information in the web.xml
file.
There are tags to create a home instance, create an EJB instance, and iterate through a collection of EJBs. Table 1-8 summarizes the EJB tag library. See "EJB Tags" for more information.
Table 1-8 Summary of EJB Tag Library
Tag | Description | Attributes |
---|---|---|
useHome |
Look up the home interface for the EJB and create an instance of it. |
id, type, location, local |
useBean |
Instantiate and use the EJB. The functionality is similar to that of the standard |
id, type, value, scope, local |
createBean |
For first instantiating an EJB, if you do not use the |
instance |
iterate |
Iterate through a collection of EJB instances (more typical for entity beans). |
id, type, collection, max |
OC4J has utility tags for displaying a date, displaying an amount of money in the appropriate currency, displaying a number, iterating through a collection, evaluating and including the tag body (depending on whether the user belongs to a specified role), and displaying the last modification date of the current file. Table 1-9 summarizes these tags. See "General Utility Tags" for more information.
Table 1-9 Summary of General Utility Tag Library
Tag | Description | Attributes |
---|---|---|
displayCurrency |
Display a specified amount of money, formatted as currency for the locale. |
amount, locale |
displayDate |
Display a specified date, formatted appropriately for the locale. |
date, locale |
displayNumber |
Display the specified number, for the locale and optionally in the specified format. |
number, locale, format |
iterate |
Iterate through a collection. |
id, type, collection, max |
ifInRole |
Evaluate the tag body and include it in the body of the JSP page, depending on whether the user is in the specified application role. |
role, include |
lastModified |
Display the date of the last modification of the current file, in appropriate format for the locale. |
locale |
This section provides the following information:
An introduction to caching features supported by the Oracle Application Server in general and the OC4J JSP container in particular
A discussion of the role of the OC4J Web Object Cache in relation to other Oracle Application Server caching components
A summary of tag libraries relating to caching features
The Oracle tag libraries introduced in this section comply with JSP standards.
Note: See the OC4J demos for sample applications using the features introduced in this section. The can be downloaded from the following location on the Oracle Technology Network:
|
The Oracle Application Server and OC4J provide the following caching features:
Oracle Application Server Web Cache
This is an HTTP-level cache, maintained outside the application, providing very fast cache operations. It is a content-based cache, capable of caching static data (such as HTML, GIF, or JPEG files) or dynamic data (such as servlet or JSP results). Given that it exists as a content-based cache outside the application, it cannot cache objects (such as Java objects or XML DOM objects) in a Java object format. In addition, post-processing operations applicable to cached data cannot be coded in Java and are predefined by the cache itself.
The OracleAS Web Cache provides an ESI processor to support Edge Side Includes, an XML-style markup language that allows dynamic content assembly away from the Web server. This technology enables you to separate cacheable pages into distinct cached objects, as desired. OC4J supports this technology through its JESI tag library.
For an overview of Edge Side Includes and the OracleAS Web Cache, as well as detailed documentation of the JESI tag library, see Chapter 6, "JESI Tags for Edge Side Includes".
For additional information about the OracleAS Web Cache, see the Oracle Application Server Web Cache Administrator's Guide.
OC4J Web Object Cache
This is an application-level cache that is embedded and maintained within a Java Web application. It is a hybrid cache, both Web-based and object-based. A custom tag library or API enables you to define page fragment boundaries and to capture, store, reuse, process, and manage the intermediate and partial execution results of JSP pages and servlets as cached objects. Each page fragment can produce a separate cache object. The produced objects can be HTML or XML text fragments, XML DOM objects, or Java serializable objects. These objects can be cached conveniently in association with HTTP request and session semantics. Alternatively, they can be reused outside HTTP, such as when an application outputs cached XML objects through Simple Mail Transfer Protocol (SMTP), Java Messaging Service (JMS), Advanced Queueing (AQ), or Simple Object Access Protocol (SOAP).
For more information, see Chapter 7, "Web Object Cache Tags and API".
Oracle Application Server Java Object Cache
The Oracle Application Server Java Object Cache is a general-use Java cache to manage Java objects within a process, across processes, and on local disk. By managing local copies of objects that are difficult or expensive to retrieve or create, the Java Object Cache can significantly improve application performance. By default, the OC4J Web Object Cache uses the Oracle Application Server Java Object Cache as its underlying cache repository.
For details about the Java Object Cache, see the Oracle Application Server Containers for J2EE Services Guide.
It is important to understand the role of the OC4J Web Object Cache in the overall setup of a Web application. It works at the Java level and is closely integrated with the HTTP environment of servlet and JSP applications. By contrast, the Oracle Application Server Java Object Cache works at the Java object level, but is not integrated with HTTP. As for the OracleAS Web Cache, it is well integrated with HTTP and is orders of magnitude faster than the Web Object Cache, but it does not operate at the Java level and cannot be directly invoked by Web application code. For example, it cannot apply a style sheet to a cached DOM object within the J2EE container, reuse the cached result in other protocols, or allow direct DOM operations. OracleAS Web Cache can, however, apply a style sheet to text-based XML documents, as opposed to DOM objects, that were cached from the original Web server through HTTP.
The Web Object Cache is not intended for use as the main Web cache for an application. It is an auxiliary cache embedded within the same Java virtual machine that is running your servlets and JSP pages. Because the retrieval path for cached results in the Web Object Cache includes the JVM and the JSP and servlet engines, it generally takes much longer to serve a page from the Web Object Cache compared to the OracleAS Web Cache.
The Web Object Cache does not replace or eliminate the need for either the OracleAS Web Cache or the Oracle Application Server Java Object Cache. It is a complementary caching component in the overall framework of a Web application and should be used together with the other caching products, as appropriate. In fact, the Web Object Cache uses the Java Object Cache as its default repository. And through combined use of the OC4J JESI tags and Web Object Cache tags, you can use the Web Object Cache and OracleAS Web Cache together in the same page.
Think of the OracleAS Web Cache as the primary caching component. It serves cached pages directly to HTTP clients and handles large volumes of HTTP traffic quickly, fitting the requirements of most Web sites. You can use the OracleAS Web Cache to store complete Web pages or partial pages (through use of the JESI tags). Cached pages can be customized, to a certain extent, before being sent to a client, including cookie-replacement and page-fragment concatenation, for example.
It is advisable to use the OracleAS Web Cache as much as possible to speed up response and reduce the load on the Web application server and back-end database. The caching needs of a large percentage of Web pages can be addressed by the OracleAS Web Cache alone.
As a complement to the OracleAS Web Cache, you can use the Web Object Cache to capture intermediate results of JSP and servlet execution and subsequently reuse these cached results in other parts of the Java application logic. It is not beneficial to use the Web Object Cache in your Web application unless you can repeatedly reuse objects after they are cached and you require post-processing on cached objects before they are served to a client.
In comparison to the Oracle Application Server Java Object Cache, the Web Object Cache makes it much easier to store and maintain partial execution results in dynamic Web pages. The Java Object Cache, being a pure object-based framework for any general Java application, is not aware of any HTTP environment in which it might be embedded. For example, its cache keys do not automatically depend on HTTP cookies or sessions. When you directly use the Java Object Cache within a Web application, you are responsible for creating any necessary interfacing with resulting Web pages. The Java Object Cache provides only a programmatic way to specify cache maintenance policies, whereas the Web Object Cache allows the alternative of specifying policies through configuration files.
OC4J supplies two tag libraries for use with Oracle Application Server caching features:
JESI tag library
Web Object Cache tag library
This section summarizes those libraries.
OC4J provides the JESI tag library as a convenient interface to ESI tags and Edge Side Includes functionality for Web caching. Developers have the option of using ESI tags directly in any Web application, but JESI tags provide additional convenience in a JSP environment.
Table 1-10 summarizes the JESI tag library. See "Oracle JESI Tag Descriptions" for more information.
Table 1-10 Summary of JESI Tag LIbrary
Tag | Description | Attributes |
---|---|---|
control |
Control caching characteristics for JSP pages in the control/include usage model. You can use a JESI |
expiration, maxRemovalDelay, cache, control |
include |
This tag, like a standard |
page, alt, ignoreError, copyParam, flush |
param |
This is a subtag of the JESI |
name, value |
template |
Use this tag (together with JESI |
expiration, maxRemovalDelay, cache, control |
fragment |
Use one or more JESI |
expiration, maxRemovalDelay, cache, control |
codeblock |
This is a subtag of the JESI |
execute |
invalidate |
Use this tag, with its JESI |
url, username, password, config, output |
object |
Use this required subtag of the JESI |
uri, prefix, maxRemovalDelay |
cookie |
Optionally use this subtag of the JESI |
name, value |
header |
Optionally use this subtag of the JESI |
name, value |
personalize |
Use this tag to allow page customization, by directing the ESI processor to perform cookie value substitution for every request for an object. |
name, default |
The OC4J Web Object Cache is a mechanism that allows Web applications written in Java to capture, store, reuse, post-process, and maintain the partial and intermediate results generated by a dynamic Web page, such as a JSP page or servlet. The programming interfaces it provides are a tag library (for use in JSP pages) and a Java API (for use in servlets).
Table 1-11 summarizes the Web Object Cache tag library. See "Web Object Cache Tag Descriptions" for more information.
Table 1-11 Summary of Web Object Cache Tag LIbrary
Tag | Description | Attributes |
---|---|---|
cache |
Use this tag to cache an object, for example a text fragment, in a JSP application. (Note, however, that there are separate tags for caching XML DOM objects or Java serializable objects.) |
policy, ignoreCache, invalidateCache, scope, autoType, selectedParam, selectedCookies, reusableTimeStamp, reusableDeltaTime, name, expirationType, TTL, timeInaDay, dayInaWeek, dayInaMonth, writeThrough, printCacheBlockInfo, printCachePolicy, cacheRepositoryName, reportException |
cacheXMLObj |
Generally speaking, use this tag instead of the |
All attributes of the |
useCacheObj |
Use this tag to cache any Java serializable object. The |
All attributes of the |
cacheInclude |
This tag combines functionality of the |
policy, page, printCacheBlockInfo, reportException |
invalidateCache |
Use this tag to programmatically invalidate a cache object. Most attributes of the |
policy, ignoreCache, scope, autoType, selectedParam, selectedCookies, name, invalidateNameLike, page, autoInvalidateLevel, cacheRepositoryName, reportException |
With Oracle Application Server 10g Release 2 (10.1.2), the OC4J JSP product includes an implementation of the JavaServer Pages Standard Tag Library (JSTL), as specified in the Sun Microsystems JavaServer Pages Standard Tag Library, Version 1.0 specification. The following sections provide an overview of JSTL features and OC4J support:
For complete information about JSTL, refer to the specification at the following location:
http://www.jcp.org/aboutJava/communityprocess/first/jsr052/index.html
Note: JSTL 1.0 requires a JSP 1.2 environment. |
JSTL is intended as a convenience for JSP page authors who are not familiar or not comfortable with scripting languages such as Java. Historically, scriptlets have been used in JSP pages to process dynamic data. With JSTL, the intent is for JSTL tag usage to replace the need for scriptlets.
Readers who have used previous versions of the OC4J JSP product will recognize this as similar to the goals of the Oracle JavaServer Pages Markup Language (JML) tag library. While the JML tag library is still supported, use of the standard JSTL is encouraged. Also see "JSTL Usage Notes and Future Considerations".
Key JSTL features include the following:
JSTL expression language (EL)
The expression language further simplifies the code required to access and manipulate application data, making it possible to avoid request-time expressions as well as scriptlets. See the next section, "Summary of JSTL Expression Language".
Core tags for expression language support, conditional logic and flow control, iterator actions, and access to URL-based resources
Tags for XML processing, flow control, and XSLT transformations
SQL tags for database access
Tags for I18N-capable internationalization and formatting
(The term "I18N" refers to an internationalization standard.)
Tag support is broken into four JSTL sublibraries according to the preceding functional areas. Table 1-12 shows the standard TLD URI and prefix for each sublibrary.
Table 1-12 JSTL Sublibraries
Functionality | URI | Prefix |
---|---|---|
Core |
|
c: |
XML processing |
|
x: |
SQL database access |
|
sql: |
I18N internationalization and formatting |
|
fmt: |
See "Overview of JSTL Tags and Additional Features" for more information.
Note: Given the constraints of having to work with JSP 1.2 containers, the JSTL 1.0 implementation was required to support both the expression language model and the request-time expression model. This dual support is accomplished through parallel JSTL sublibraries. For each sublibrary (core, XML, SQL, and I18N) there are separate TLDs, and hence separate TLD URIs, for the two versions.It is expected that most users will want to use the expression language model, corresponding to the URIs listed previously. To use the request-time expression model, add " |
The JSTL expression language makes use of the fact that JSP scoped attributes and request parameters are the preferred vehicles for passing information to and from JSP pages. By using the JSTL expression language, you can avoid having to use JSP scriptlets and request-time expressions.
In JSTL 1.0, the expression language can be used only in JSTL tag attribute values.
As an example, consider the following use of the JSTL c:if
tag to pick out steel-making companies from a company list:
<c:if test="${company.industry == 'steel'}"> ... </c:if>
The rest of this section summarizes JSTL expression language syntax and documents how to enable JSTL expression language evaluation in your OC4J JSP applications.
This following list offers a brief summary of key syntax features of the JSTL expression language. This is followed by a few simple examples.
Invocation
The JSTL expression language is invoked through ${
expression
}
syntax. The most basic semantic is that invocation of a named variable ${foo}
yields the same result as the method call PageContext.findAttribute(foo)
.
Data structure access
To access data within JavaBeans and within collections such as lists, maps, and arrays, the expression language supports the ".
" and "[]
" constructs. The ".
" construct allows access to properties whose names are standard Java identifiers. The "[]
" construct is for more generalized access, but for valid Java identifiers is equivalent to the ".
" construct. The expressions foo.bar
and foo["bar"]
yield the same result, for example.
Relational operators
The expression language supports the relational operators ==
(or eq
), !=
(or ne
), <
(or lt
), >
(or gt
), <=
(or le
), >=
(or ge
).
Arithmetic operators
The expression language supports the arithmetic operators +
, -
, *
, /
(or div
), %
(or mod
, for remainder or modulo).
Logical operators
The expression language supports the logical operators &&
(or and
), ||
(or or
), !
(or not
), empty
.
The following example shows fairly basic invocations of the expression language, including the relational "<=
" (less than or equal to) operator.
<c:if test="${auto.price <= customer.priceLimit}"> The <c:out value="${auto.makemodel}"/> is in your price range. </c:if>
The following example, from the Sun Microsystems JavaServer Pages Standard Tag Library, Version 1.0 specification, shows use of the ".
" and "[]
" constructs:
<%-- "productDir" is a Map object containing the description of products, "preferences" is a Map object containing the preferences of a user --%> product: <c:out value="${productDir[product.custId]}"/> shipping preference: <c:out value="${user.preferences['shipping']}"/>
JSTL offers the following implicit objects:
pageScope
: Allows access to page-scope variables.
requestScope
: Allows access to request-scope variables.
sessionScope
: Allows access to session-scope variables.
applicationScope
: Allows access to application-scope variables.
pageContext
: Allows access to all properties of the page context of a JSP page.
param
: This is a Java Map
object where param["foo"]
returns the first string value associated with the request parameter foo
.
paramValues
: Use paramValues["foo"]
, for example, to return an array of all string values associated with request parameter foo
.
header
: Similarly to using param
, you can use this to access the first string value associated with a request header.
headerValues
: Similarly to using paramValues
, you can use this to access all string values associated with a request header.
initParam
: Allows access to context initialization parameters.
cookie
: Allows access to cookies received in the request.
The expression language also offers the following features:
It can provide default values where failure to evaluate an expression is considered to be recoverable.
Where application data might not exactly match the type expected by a tag attribute or expression language operator, there are rules to convert the type of the resulting value to the expected type.
See the JSTL 1.0 specification for information.
The following sections provide a summary of JSTL tags and discuss some additional JSTL features:
JSTL tags make data available through JSP scoped attributes, referred to as scoped variables, which are used in place of scripting variables. JSTL tags that can make data available in this way have var
and scope
among their attributes, used as follows:
var
: the variable that is to be exposed
scope
: the scope of the variable, either page
(default), request
, session
, or application
The scope
attribute would not be relevant for NESTED
variables (which would always have page
scope), but variables in the JSTL are AT_END
(available from the end-tag to the end of the page).
The following example uses the core library iterator action tag forEach
and expression language support tag out
to expose the current item of an employees
collection:
<c:forEach var="employee" items="${customers}"> The current employee is <c:out value="${customer}"/> </c:forEach>
JSTL includes functionality to dynamically override JSP configuration data for a particular scope, through a scoped variable. You can accomplish this using functionality of the javax.servlet.jsp.jstl.core.Config
class.
According to the JSP specification, all scopes (page
, request
, session
, and application
) that exist within a JSP page context should together form a single namespace; that is, the name of a scoped variable should be unique across execution of a page.
The Config
class has functionality to transparently manipulate configuration parameter names to produce the effect that each scope has its own namespace. Effectively, this enables you to set a configuration parameter for a particular scope only.
See the JSTL 1.0 specification for information.
Table 1-13 summarizes the JSTL tags, organized into functional groups. The JSTL standard tag prefix is noted for each group.
Table 1-13 Summary of JavaServer Pages Standard Tag Library
Tag Group | Description of Group | Individual Tags |
---|---|---|
Core, EL support |
Includes tags to evaluate an expression and output the result to the current |
c:out, c:set, c:remove, c:catch |
Core, conditional |
Includes tags to evaluate body content if a test attribute evaluates as |
c:if, c:choose, c:when, c:otherwise |
Core, iterators |
Includes tags to iterate body execution over a collection of objects, or a specified number of times, and iterate over a set of tokens separated by supplied delimiters. |
c:forEach, c:forTokens |
Core, URL-related |
Includes tags to import the content of a URL-based resource, create a URL using appropriate rewriting rules, send an HTTP redirect to the client, and add a request parameter to a URL. The |
c:import, c:url, c:redirect, c:param |
XML, core |
Includes tags to parse an XML document, evaluate an XPath expression and output the result to the current |
x:parse, x:out, x:set |
XML, flow control |
Includes tags to evaluate a specified XPath expression and render its content if the expression evaluates as true, specify mutually exclusive conditional execution paths, and evaluate a specified XPath expression and repeat body execution over the result. The |
x:if, x:choose, x:when, x:otherwise, x:forEach |
XML, transforms |
Includes tags to apply an XSLT style sheet transformation to a document, and set transformation parameters. The |
x:transform, x:param |
SQL |
Includes tags to query a database, update a database ( |
sql:query, sql:update, sql:transaction, sql:setDataSource, sql:driver, sql:param, sql:dateParam |
I18N, internationalization |
Includes tags to store a specified locale in the locale configuration variable, create an I18N localization context for use within the tag, create a localization context and store it for use outside the tag, look up a localized message in a resource bundle, and set the request character encoding. The |
fmt:locale, fmt:bundle, fmt:message, fmt:param, fmt:requestEncoding |
I18N, formatting |
Includes tags to specify a time zone for formatting or parsing, store a specified time zone in a scoped variable or time zone configuration variable, format a numeric value as appropriate for a locale or special customization, parse the string representation of a numeric value that had been formatted for a locale or special customization, format a date or time for a locale or special customization, and parse the string representation of a date or time that had been formatted for a locale or special customization. |
fmt:timeZone, fmt:setTimeZone, fmt:formatNumber, fmt:parseNumber, fmt:formatDate, fmt:parseDate |
Note: JSTL tags for XML processing are based on XPath (XML Path), a W3C recommendation. XPath provides a concise notation for specifying and selecting parts of an XML document. Refer to the following Web site for information:
|
Be aware off the following considerations:
The Oracle Application Server 10g Release 2 (10.1.2) JSTL implementation is based on the Jakarta 1.0.3 JSTL version and is suitable for use with OC4J. See the following location for more information about Jakarta:
http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
The custom JML, XML, and data-access (SQL) tag libraries provided with OC4J pre-date JSTL and have areas of duplicate functionality. For standards compliance, it is now generally advisable to use JSTL instead of the custom libraries, and Oracle plans to desupport the JML library in future releases. For features in the custom libraries that are not yet available in JSTL, where there seems to be general usefulness, Oracle will try to have the features adopted into the JSTL standard as appropriate.
For the filter functionality of JSTL XML tags to work in OC4J, you must set the SAX driver when starting OC4J. Otherwise, the JSTL demo Filter.jsp
gives the following exception:
javax.servlet.jsp.JspException: System property org.xml.sax.driver not specified
When starting OC4J standalone, use the following option in the command line:
-Dorg.xml.sax.driver=oracle.xml.parser.v2.SAXParser
When starting Oracle Application Server, you can specify this setting through the system properties.
A number of other Oracle components, outside OC4J, provide JSP tag libraries. The following sections summarize these libraries:
The Oracle tag libraries introduced in this section comply with JSP standards.
The following discussion assumes some prior knowledge of the underlying components.
Oracle Application Development Framework (Oracle ADF), offered as part of Oracle JDeveloper, includes the component technology Oracle ADF Business Components. This includes a library of custom Business Components data tags.
These data tags provide a simple tag-based approach for interaction with Business Components data sources, allowing complete access to business components with viewing, editing, and full DML control capabilities. The tag-based approach to building JSP applications with Business Components does not require extensive Java programming and is very much like coding an HTML page.
For more information, refer to the Oracle JDeveloper online help or to the following location on the Oracle Technology Network:
http://www.oracle.com/technology/products/jdev/content.html
Oracle JDeveloper provides a set of custom tags known as User Interface Extension (UIX) tags. The tags invoke UIX controls, generating the HTML to render tabs, buttons, tables, headers, and other layout and navigational components that implement the Oracle browser look and feel.
The tags are included on several palette pages: UIX JSP Border Layout, UIX JSP Form, UIX JSP Layout, UIX JSP Message Components, UIX JSP Page Layout, UIX JSP Simple Components, and UIX JSP Table.
For more information, refer to the Oracle JDeveloper online help or to the following location on the Oracle Technology Network:
http://www.oracle.com/technology/products/jdev/content.html
UIX JSP pages can include both Business Components data tags and Business Components UIX convenience tags that simplify the presentation of data.
The Business Components UIX convenience tags rely on an ApplicationModule
data tag to get the data source from the Business Components application module. In addition to the Business Components UIX tags, you can use the (non-UIX) Business Components tags in UIX JSP pages.
For more information, refer to the Oracle JDeveloper online help or to the following location on the Oracle Technology Network:
http://www.oracle.com/technology/products/jdev/content.html
Oracle Reports consists of Oracle Reports Developer (a component of the Oracle Developer Suite) and Oracle Reports Services (a component of the Oracle Application Server). The Oracle Reports Developer includes tags integrated with data model objects that are used to create JSP reports. The Oracle Reports custom tags allow you to quickly add report blocks and graphs to existing JSP files. These tags can be used as templates to enable you to build and insert your own data-driven Java component into an HTML page for a JSP-based Web report.
Key tags delimit and define the report block. Inside these tags, other tags define the content and the look and feel of the report data.
For more information, refer to the Oracle Reports Developer online help, available through the Help menu in Reports Builder. You can also find more information about Oracle Reports on the Oracle Technology Network:
http://www.oracle.com/technology/products/reports/index.html
Developers of location-based applications need specialized services for the following:
Geocoding: associating geographical coordinates with addresses
Mapping: providing a graphical map for a point, set of points, route, or driving maneuver
Routing: providing driving directions
Business directories ("yellow pages"): listing businesses by region and by either category or name
Traffic: providing information about accidents, construction, and other incidents that affect traffic flow
The OracleAS Wireless location application components compose an API for performing geocoding, providing driving directions, and looking up business directories. Service proxies are included that map existing key providers to the API, and additional providers are expected to be accommodated in the future.
For JSP developers, a tag library is provided. For more information, refer to the Oracle Application Server Wireless Developer's Guide.
The OracleAS MapViewer is a programmable tool for rendering maps using spatial data managed by Oracle Spatial or Oracle Locator (also referred to as Locator). OracleAS MapViewer provides tools that hide the complexity of spatial data queries and cartographic rendering, while providing customizable options for more advanced users. These tools can be deployed in a platform-independent manner and are designed to integrate with map-rendering applications.
For convenience, OracleAS MapViewer includes a JSP tag library that you can use to submit map requests.
For more information, see the Oracle Application Server MapViewer User's Guide.
Oracle Ultra Search provides a custom tag library for use by developers in incorporating content search functionality into JSP applications. The library includes the following functionality:
The ability to retrieve search attributes, groups, languages, and lists of values (LOVs) for rendering the advance query form
The ability to iterate through the resulting hit set and retrieve document attributes and properties for rendering the result page
The ability to perform a search with "relevance boosting" and an estimation of the total hit count
For more information, see the Oracle Ultra Search Administrator's Guide. Alternatively, refer to the Oracle Ultra Search online documentation, under Oracle Ultra Search JSP Tag Library.
With OracleAS Portal, developers can accomplish the following:
Build and deploy Internet portals to deliver relevant information and applications to customers, employees, and partners.
Develop portals rapidly, without code, using productive online tools.
Increase user productivity with single sign-on and self-service publishing.
Add value quickly with over 250 prebuilt portlets based on open standards.
The OracleAS Portal tag library provides further convenience for developers building customizable Internet portals. A developer can create internal JSP pages, which are stored inside the Portal database and downloaded when the portal is executed, or external JSP pages, which are stored in the file system, or some combination.
For more information, refer to Oracle Application Server Integrating JavaServer Pages with OracleAS Portal, available through the Oracle Technology Network:
http://www.oracle.com/technology/products/ias/portal/pdf/pd_jsps_10g.pdf
The Oracle Business Intelligence Beans (OracleBI Beans) product consists of Java components, utilities, and a JSP tag library that enable rapid development of analytical applications. OracleBI Beans applications leverage the capabilities of OLAP in Oracle Database. Using OracleBI Beans, you can develop both HTML-client and Java-client applications.
Note: The OracleBI Beans product is a component of the Oracle Developer Suite (OracleDS) and is for use with Oracle JDeveloper. |
OracleBI Beans includes the following groups of Java components:
Presentation beans: beans that let you view, manipulate, and print data
OLAP beans: beans that interact with an Oracle OLAP data source
Persistence service: a set of Java packages that support the storage and retrieval of object definitions in the OracleBI Beans Catalog
For further developer convenience, OracleBI Beans includes a JSP tag library. You can use JDeveloper to create OracleBI Beans JSP pages. A JDeveloper wizard prompts you for information related to the tag that you want to use and inserts the coded tag in the JSP page.
For more information, refer to the OracleBI Beans online help. Under "Building Web Modules", click "Using JSP Tags", then "List of BI Beans JSP Tags".
Oracle Application Server provides the Multimedia Tag Library, a custom JSP tag library for use by developers and Web page authors when generating multimedia HTML tags in JSP pages and uploading multimedia data into interMedia objects.
Oracle interMedia enables Oracle Database to store, retrieve, manage, and manipulate images, audio, video, and other media data, while integrating it with other enterprise information. Specifically, Oracle interMedia supports media storage, media retrieval, media management, and manipulation of media data managed by Oracle and stored in binary large objects, file-based large objects, URLs that contain media data, and specialty servers. Oracle interMedia is accessible to applications through relational and object interfaces.
Oracle interMedia uses object types that are similar to Java classes to describe media data. These interMedia objects have a common media data storage model. Oracle interMedia also provides Java classes to enable users to write Java applications using interMedia objects. There are also Oracle interMedia Java classes for servlets and JavaServer Pages to facilitate retrieving and uploading media data from and to Oracle Database instances.
The Multimedia Tag Library includes a set of tags for retrieving media data and a set for uploading media data. The Multimedia JSP tags for media retrieval include a set of common attributes and tag-specific media-render-attributes. The common attributes are: custom-retrieval-attributes, database-connection-attributes, media-access-attributes, media-cache-control-attributes, and table-and-column-attributes. The media-render-attributes are described with each media retrieval tag.
See Oracle Application Server Multimedia Tag Library for JSP User's Guide and Reference for additional information about the Multimedia JSP tags.