Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference Release 2 (9.0.2) Part Number A95883-01 |
|
This manual documents tag libraries, JavaBeans, and other utilities supplied with OC4J that are implemented according to industry standards and are generally portable to other JSP or servlet environments. There is also a section summarizing tag libraries provided with other components of the Oracle9i Application Server.
Oracle-specific features, as well as an introduction to the OC4J JSP container and standard JSP technology, are covered in the Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference.
This chapter covers the following topics:
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.
The Oracle extensions introduced in this section are implemented through standard tag libraries or custom JavaBeans and are generally portable to other JSP environments.
Here is a list of the topics covered:
For the syntax documentation in tag descriptions throughout this manual, note the following:
[...]
<%=
jspExpression %>"
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:
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.
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, 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".
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--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. Note that these tags are portable to other JSP environments.
There is additional XML support as well:
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 Oracle-specific XML support in the Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference.
OC4J supplies a set of custom JavaBeans for use in accessing the Oracle9i 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".
Although the Sun Microsystems JavaServer Pages Specification, Version 1.1 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".
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 personalize 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.
Oracle9iAS Personalization uses data mining algorithms in the Oracle database to choose the most relevant content available for a user. Recommendations are calculated by an Oracle9iAS 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 Oracle9iAS 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 lower level Java API of the recommendation engine.
Table 1-4 summarizes the Oracle9iAS Personalization Tag Library. See Chapter 9, "Oracle9iAS Personalization Tags" for information.
OC4J provides utility tags to accomplish the following from within Web applications:
For sending e-mail messages, you can use the sendMail
tag or the oracle.jsp.webutil.email.SendMailBean
JavaBean. Table 1-5 summarizes the sendMail
tag. See "Mail JavaBean and Tag" for more information.
Tag | Description | Attributes |
---|---|---|
sendMail |
Send an e-mail message from a JSP page. Tag functionality includes globalization support. |
host |
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".
For using EJBs, there are tags to create a home instance, create an EJB instance, and iterate through a collection of EJBs. Table 1-7 summarizes the EJB tag library. See "EJB Tags" for more information.
There are also 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-8 summarizes these tags. See "General Utility Tags" for more information.
This section provides the following information:
The Oracle9i Application Server and OC4J provide the following caching features:
This is an HTTP-level cache, maintained outside the application, providing very fast cache operations. It is a pure, 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 flat content-based cache outside the application, it cannot cache objects (such as Java objects or XML DOM objects) in a structured format. In addition, it has relatively limited post-processing abilities on cached data.
The Oracle9iAS 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 allows you to break cacheable pages into separate cached objects, as desired. OC4J supports this technology through its JESI tag library.
For an overview of Edge Side Includes and the Oracle9iAS 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 Oracle9iAS Web Cache, see the Oracle9iAS Web Cache Administration and Deployment Guide.
This is an application-level cache, 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 allows 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 block can produce its own resulting 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 semantics. Alternatively, they can be reused outside HTTP, such as in outputting 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".
The Oracle9i Application Server Java Object Cache is a general-use 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 significantly improves server performance. By default, the OC4J Web Object Cache uses the Oracle9i Application Server Java Object Cache as its underlying cache repository.
For details, see theOracle9iAS 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 Oracle9i Application Server Java Object Cache works at the Java object level, but is not integrated with HTTP. As for the Oracle9iAS Web Cache, it is well integrated with HTTP and is an order of magnitude faster than the Web Object Cache, but it does not operate at the Java level. For example, it cannot apply a stylesheet to a cached DOM object within the J2EE container, reuse the cached result in other protocols, or allow direct DOM operations. (Oracle9iAS Web Cache can, however, apply a stylesheet to raw 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 Oracle9iAS Web Cache.
The Web Object Cache does not replace or eliminate the need for either the Oracle9iAS Web Cache or the Oracle9i 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 Oracle9iAS Web Cache together in the same page.
Think of the Oracle9iAS 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 Oracle9iAS 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 Oracle9iAS Web Cache as much as possible to 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 Oracle9iAS Web Cache alone.
As a complement to the Oracle9iAS 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 are doing a significant amount of post-processing on cached objects between the time they are cached and the time they are served to a client.
In comparison to the Oracle9i 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 the HTTP environment in which it may be embedded. For example, it does not directly 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. The Java Object Cache does not provide a way to specify maintenance policies declaratively.
OC4J supplies two tag libraries for use with Oracle9iAS caching features:
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-9 summarizes the JESI tag library. See "Oracle JESI Tag Descriptions" for more information.
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 or servlet. For programming interfaces, it provides a tag library (for use in JSP pages) and a Java API (for use in servlets).
Table 1-10 summarizes the Web Object Cache tag library. See "Web Object Cache Tag Descriptions" for more information.
A number of other Oracle9iAS components provide JSP tag libraries. This section summarizes the following libraries:
Some prior knowledge of these components is helpful.
Oracle9i JDeveloper provides set of JSP 1.1-compliant custom tags known as Business Components for Java (BC4J) data tags. BC4J data tags provide a simple tag-based approach for interaction with business component data sources. The tags provide complete access to business components and allow viewing, editing, and full DML control.
Custom data tags allow for simplified interaction with Business Components for Java data sources. 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.
Table 1-11 summarizes the BC4J tag library. The typical tag prefix is jbo
.
For more information, refer to the Oracle9i JDeveloper online help, or their documentation on the Oracle Technology Network:
http://otn.oracle.com/products/jdev/content.html
Oracle9i JDeveloper provides set of JSP 1.1-compliant 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 Page, UIX Layout, UIX Table, UIX Form, UIX Border Layout, and BC4J UIX. These support page layout, table layout, form layout, border layout, and data-binding to a business components project.
Table 1-12 summarizes the UIX tag library. The typical tag prefix is uix
.
For more information, refer to the Oracle9i JDeveloper online help, or their documentation on the Oracle Technology Network:
http://otn.oracle.com/products/jdev/content.html
UIX JSP pages can include both BC4J data tags and BC4J UIX convenience tags that simplify the presentation of data.
The BC4J UIX convenience tags rely on an ApplicationModule
data tag to get the data source from the BC4J application module. In addition to the BC4J UIX tags listed here, you can use the (non-UIX) BC4J tags in UIX JSP pages.
Table 1-13 summarizes the BC4J/UIX tags. The typical tag prefix is bc4juix
.
For more information, refer to the Oracle9i JDeveloper online help, or their documentation on the Oracle Technology Network:
http://otn.oracle.com/products/jdev/content.html
Oracle9i Reports tags integrate with data model objects that are used to create Oracle reports. The 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 a Reports HTML page.
An example of a custom JSP tag is the 3D Graphics charting component. Using a custom JSP tag, you can pass Reports data to the 3D application server, which creates an image of the chart. The custom JSP tag then returns HTML to reference the created image.
The report
and objects
tags, respectively, delimit and define the report block. Inside these tags, other custom tags define the content and the look and feel of the report data.
Table 1-14 summarizes the Reports tags. The typical tag prefix is rw
.
For more information, refer to the Oracle9i Reports Developer online help, under "Reference/JSP Tags". You can also find more information about Reports on the Oracle Technology Network:
http://otn.oracle.com/products/reports/content.html
Developers of location-based applications need specialized services for the following:
The Oracle9iAS Wireless location application components are a set of APIs for performing geocoding, providing driving directions, and looking up business directories. Service proxies are included that map existing important providers to the APIs, and additional providers are expected to be accommodated in the future.
For JSP developers, a tag library is provided, as summarized in Table 1-15. The typical tag prefix is loc
.
For more information, refer to the Oracle9iAS Wireless Developer's Guide.
Oracle9iAS 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 tag library is summarized in Table 1-16. The typical tag prefix is US
.
For more information, refer to the Ultra Search online documentation, under "Ultra Search JSP Tag Library".
With Oracle9iAS Portal, developers can accomplish the following:
The Oracle9iAS 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.
The tag library is summarized in Table 1-17. The typical tag prefix is portal
.
For more information, refer to the document Oracle9i Application Server Portal: Adding JSPs, available through the Oracle Technology Network:
http://otn.oracle.com
|
Copyright © 2002 Oracle Corporation. All Rights Reserved. |
|