Skip Headers
Oracle® Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference
10g Release 2 (10.1.2)
B14016-02
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

1 Overview of Tag Libraries and Utilities

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):
http://www.oracle.com/technology/tech/java/oc4j/demos/

Overview of Tag Libraries and Utilities Provided with OC4J

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:

  • See "Summary of Oracle Caching Support for Web Applications" for information about tag libraries provided with OC4J to support caching features.

  • See the OC4J demos for sample applications using the features introduced in this section. They can be downloaded from the following location on the Oracle Technology Network (requiring an OTN membership, which is free of charge):

http://www.oracle.com/technology/tech/java/oc4j/demos/

Tag Syntax Symbology and 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.

Overview of Extended Type JavaBeans

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

Overview of JspScopeListener for Event-Handling


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

Overview of Integration with XML and XSL

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 transform tag.

href, fromXMLObjName, toXMLObjName, toWriter

parsexml

Convert from an input stream to an XML DOM object.

resource, toXMLObjName, validateResource, root


Summary of Data-Access JavaBeans and Tag Library

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 dbQuery or dbExecute tag.

name, value, scope

dbSetCookie

Set a cookie.

name, value, domain, comment, maxAge, version, secure, path


Summary of JSP Markup Language (JML) Custom Tag Library


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 jsp:useBean tag for declaring simple variables.

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 if tag is executed.

condition

choose

The choose tag, with associated when and otherwise tags, provides a multiple conditional statement.

(None)

when

This is used with the choose tag.

condition

otherwise

This is optionally used with the choose and when tags.

(None)

for

This tag provides the ability to iterate through a loop, as with a Java for loop.

id, from, to

foreach

This tag provides the ability to iterate over a homogeneous set of values in a Java array, Enumeration instance, or Vector instance.

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

Summary of Oracle Application Server Personalization Tag Library

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


Summary of Web Services Tag Library

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 map tags nested within a webservice tag to have the Web service proxy add entries to the SOAP mapping registry for type mapping between SOAP/XML and Java. Use one map tag for each desired type mapping.

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 invoke tag gains access to a Web service proxy either by being nested within a webservice tag or by accessing a Web service proxy scripting variable created in a webservice tag.

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


Summary of File Access and Mail Tags

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.

Table 1-7 Summary of sendMail Tag

Tag Description Attributes

sendMail

Send an e-mail message from a JSP page. Tag functionality includes globalization support.

host, sender, recipient, cc, bcc, subject, contentType, contentEncoding, serverAttachment, clientAttachment


Summary of EJB Tags

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 jsp:useBean tag for a JavaBean.

id, type, value, scope, local

createBean

For first instantiating an EJB, if you do not use the value attribute of the EJB useBean tag, you must nest an EJB createBean tag within the useBean tag to do the work of creating the EJB instance.

instance

iterate

Iterate through a collection of EJB instances (more typical for entity beans).

id, type, collection, max


Summary of JSP Utility Tags

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


Summary of Oracle Caching Support for Web Applications

This section provides the following information:

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:
http://www.oracle.com/technology/tech/java/oc4j/demos/

Oracle Application Server and JSP Caching Features

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.

Role of the JSP Web Object Cache

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.

Web Object Cache Versus OracleAS Web Cache

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.

Web Object Cache Versus Oracle Application Server Java Object Cache

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.

Summary of Tag Libraries for Caching

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.

Summary of JESI Tag Library

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 control tag in the top-level page or any included page.

expiration, maxRemovalDelay, cache, control

include

This tag, like a standard jsp:include tag, enables you to dynamically insert output from the included page into output from the including page. However, it results in the included page being processed and assembled by the ESI processor, typically inside OracleAS Web Cache.

page, alt, ignoreError, copyParam, flush

param

This is a subtag of the JESI include tag. You can use one or more JESI param tags to pass additional query parameters to the included page.

name, value

template

Use this tag (together with JESI fragment tags) when you are splitting a JSP page into separate cache fragments. The JESI template tag specifies caching behavior for the aggregate page, outside any fragments.

expiration, maxRemovalDelay, cache, control

fragment

Use one or more JESI fragment tags within a JESI template tag, between the JESI template start-tag and end-tag, to denote separately cacheable fragments.

expiration, maxRemovalDelay, cache, control

codeblock

This is a subtag of the JESI template tag. You can use JESI codeblock tags to specify conditional execution of code blocks within the template code.

execute

invalidate

Use this tag, with its JESI object subtag, to explicitly invalidate one or more objects cached by OracleAS Web Cache.

url, username, password, config, output

object

Use this required subtag of the JESI invalidate tag to specify cached objects to invalidate, according to either the complete URI or a URI prefix.

uri, prefix, maxRemovalDelay

cookie

Optionally use this subtag of the JESI object tag to use cookie information as a further criterion for invalidation.

name, value

header

Optionally use this subtag of the JESI object tag to use HTTP/1.1 header information as a further criterion for invalidation.

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


Summary of Web Object Cache Tag Library

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 cache tag if you are caching XML DOM objects. The cacheXMLObj tag supports all the cache tag attributes, as well as additional XML-specific parameters.

All attributes of the cache tag, plus: fromXMLObjName, toXMLObjName, toWriter

useCacheObj

Use this tag to cache any Java serializable object. The useCacheObj tag supports all the cache tag parameters, as well as additional attributes specific to its functionality.

All attributes of the cache tag, plus: type, id, cacheScope

cacheInclude

This tag combines functionality of the cache tag (but not the cacheXMLObj tag or useCacheObj tag) and the standard jsp:include tag.

policy, page, printCacheBlockInfo, reportException

invalidateCache

Use this tag to programmatically invalidate a cache object. Most attributes of the invalidateCache tag behave the same way as attributes of the same names in the cache tag.

policy, ignoreCache, scope, autoType, selectedParam, selectedCookies, name, invalidateNameLike, page, autoInvalidateLevel, cacheRepositoryName, reportException


Support for the JavaServer Pages Standard Tag Library

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.

Overview and Philosophy of JSTL

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

http://java.sun.com/jstl/core

c:

XML processing

http://java.sun.com/jstl/xml

x:

SQL database access

http://java.sun.com/jstl/sql

sql:

I18N internationalization and formatting

http://java.sun.com/jstl/fmt

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 "_rt" to each URI in order to access the appropriate TLDs. By convention, add "_rt" to each prefix as well ("c_rt:", for example).


Summary of JSTL Expression Language

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.

JSTL Expression Language Syntax

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.

Example: Basic

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>
Example: Accessing Collections

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 Expression Language Implicit Objects

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.

JSTL Expression Language Additional Features

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.

Overview of JSTL Tags and Additional Features

The following sections provide a summary of JSTL tags and discuss some additional JSTL features:

Scoped Variables

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>

Configuration Data and the Config Class

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.

JSTL Tag Summary

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 JspWriter object, set the value of a scoped variable or of a property of a target object, remove a scoped variable, and catch a Throwable instance thrown by a nested action.

c:out, c:set, c:remove, c:catch

Core, conditional

Includes tags to evaluate body content if a test attribute evaluates as true, and specify mutually exclusive conditional execution paths. The when and otherwise tags are used with the choose tag.

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 param tag is a subtag of the import, url, and redirect tags.

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 JspWriter object, and evaluate an XPath expression and store the result in a scoped variable. (See the note after this table regarding XPath.)

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 when and otherwise tags are used with the choose tag.

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 param tag is a subtag of the transform tag.

x:transform, x:param

SQL

Includes tags to query a database, update a database (UPDATE/INSERT/DELETE), establish a transaction context for queries and updates, export a data source as a scoped variable or data source configuration variable, set the values for parameter placeholders ("?") in a SQL statement, and set the values for parameter placeholders where the type is java.util.Date. The param and dateParam tags are subtags of the query and update tags.

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 param tag can be used with the message tag to replace a parameter in the message tag.

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:
http://www.w3.org/TR/xpath

JSTL Usage Notes and Future Considerations

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.

Overview of Tag Libraries from Other Oracle Components

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 ADF Business Components Tag Library

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 User Interface Extension (UIX) Tag Library

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

Oracle ADF Business Components UIX Tag Library

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 Tag Library

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

Oracle Application Server Wireless Location Tag Library

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.

Oracle Application Server MapViewer Tag Library

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 Tag Library

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.

Oracle Application Server Portal 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

Oracle Business Intelligence Beans Tag Library

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 Multimedia Tag Library

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.