Oracle9iAS Containers for J2EE Support for JavaServer Pages Developer's Guide Release 2 (9.0.3) Part Number A97679-01 |
|
The JSP container provided with Oracle9iAS Containers for J2EE (OC4J) in the Oracle9i Application Server is a complete implementation of the Sun Microsystems JavaServer Pages Specification, Version 1.2. JSP 1.2 functionality depends upon servlet 2.3 functionality, and the OC4J servlet container is a complete implementation of the Sun Microsystems Java Servlet Specification, Version 2.3.
This chapter provides overviews of the Oracle9i Application Server, OC4J, the OC4J JSP implementation and features, and custom tag libraries and utilities that are also supplied (documented in the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference).
The following topics are covered here:
This section provides a brief overview of the Oracle9i Application Server, its J2EE environment, its JSP implementation, and its Web server:
Note: Users of earlier Oracle9iAS releases can refer to Oracle9i Application Server Migrating to Release 2 (9.0.3) for information about issues in migrating to Oracle9iAS release 2. |
Oracle9i Application Server is a scalable, secure, middle-tier application server. It can be used to deliver Web content, host Web applications, connect to back-office applications, and make these services accessible to any client browser. Users can access information, perform business analysis, and run business applications on the Internet or corporate intranets or extranets. Major areas of functionality include business intelligence, e-business integration, J2EE Web services, performance and caching, portals, wireless, and management and security.
To deliver this range of content and services, the Oracle9i Application Server incorporates many components, including the Oracle HTTP Server, Oracle9iAS Web Cache, Oracle9iAS Web Services, Oracle9iAS Portal, Oracle9iAS Wireless, Oracle9iAS Forms Services and Reports Services (to support Oracle Forms-based applications and reports generation), Oracle9iAS Personalization, and various business logic runtime environments that support Enterprise JavaBeans, stored procedures, and Oracle Business Components for Java.
For its J2EE environment, Oracle9iAS provides the Oracle9iAS Containers for J2EE (OC4J), which includes the JSP container described in this manual, a servlet container, and an EJB container.
(In addition, Oracle9iAS includes an Apache JServ servlet environment, documented in Appendix B, "The Apache JServ Environment".)
OC4J is a high-performance J2EE-compliant environment providing a scalable and reliable server infrastructure by supporting clusters and load balancing. (See the Oracle9i Application Server Performance Guide for information about clustering.) With Oracle9iAS release 2 (9.0.3), OC4J complies with the J2EE 1.3 specification.
Each OC4J instance runs in a single Java virtual machine. The JVM running an OC4J instance is referred to as a node. One or more nodes--typically about two to four--form an island. Multiple islands together form a cluster. For each OC4J cluster, there is a JVM for each OC4J instance, plus a JVM for the load balancer. (Other types of clusters are possible in Oracle9iAS as well, as discussed in the Oracle9i Application Server Administrator's Guide.)
In addition to load balancing, which improves performance by distributing requests among multiple servers, the clustering mechanism provides fault tolerance, which allows any particular server to redirect a client to another server in the event of failure.
Java applications built with any development tool can be deployed to OC4J, which supports standard EAR/WAR/JAR deployment. You can debug applications deployed to OC4J through standard Java profiling and debugging facilities.
In an Oracle9iAS environment, OC4J can be fully managed and configured using the HTML-based Oracle Enterprise Manager. This includes full support for managing clustering, configuration, and deployment.
OC4J supports the following Java and J2EE services:
OC4J supplies the following J2EE containers:
The JSP bundle also supplies tag libraries to implement Web services, caching capabilities, SQL access, file access, and other features. For further overview of the JSP container provided with OC4J, see "Overview of the JSP Implementation in OC4J".
OC4J containers have been instrumented to support the Dynamic Monitoring Service (DMS) to provide runtime performance data. You can view this data through Enterprise Manager.
The OC4J servlet container supports stateful failover and cluster deployment in addition to the following key features:
The OC4J EJB container supports the following:
EJB support in OC4J also includes these features:
In a production environment, it is typical to use OC4J inside a complete Oracle9iAS environment, including the Oracle HTTP Server (as described in "Role of the Oracle HTTP Server and mod_oc4j"), Oracle9iAS Web Cache, and Enterprise Manager.
For a development environment, OC4J is also available as a standalone component by downloading OC4J_extended.zip
from the Oracle Technology Network (http://otn.oracle.com
).
When using OC4J standalone, you can use its own HTTP Web listener through port 8888. For information about OC4J standalone, see the standalone version of the Oracle9iAS Containers for J2EE User's Guide (downloadable with OC4J_extended.zip) and the Oracle9iAS Containers for J2EE Servlet Developer's Guide.
The JSP container in OC4J is compliant with the Sun Microsystems JSP 1.2 specification.
In general, a JSP 1.2 environment requires a servlet 2.3 environment, such as the OC4J servlet container. The Oracle JSP implementation, however, also supports running on Apache JServ, a servlet 2.0 environment. To make this possible, the OC4J JSP container emulates required servlet features beyond the 2.0 specification.
For a variety of reasons, though, it is generally advisable to use the OC4J servlet 2.3 environment.
This section offers additional information on the following topics:
In Oracle9iAS release 1.0.2.2, the first release to include OC4J, there were two JSP containers: 1) a container developed by Oracle and known as "OracleJSP"; 2) a container licensed from Ironflare AB and known as the "Orion JSP container".
The OracleJSP container offered several advantages, including useful value-added features and enhancements such as for globalization and SQLJ support. The Orion container also offered advantages, including superior speed, but had disadvantages as well. It did not always exhibit standard behavior when compared to the JSP reference implementation (Tomcat), and its support for internationalization and globalization was not as complete.
Oracle9iAS release 2 (9.0.2) first integrated the OracleJSP and Orion containers into a single JSP container referred to in this manual as the "OC4J JSP container". This container offers the best features of both previous versions, runs efficiently as a servlet in the OC4J servlet container, and is integrated with other OC4J containers as well. The integrated container primarily consists of the OracleJSP translator and the Orion container runtime, running with a simplified dispatcher and the OC4J core runtime classes.
The JSP container in OC4J uses the front-end servlet oracle.jsp.runtimev2.JspServlet
. See "JSP Configuration in OC4J".
For non-OC4J environments, including Apache JServ, use the old front-end servlet, oracle.jsp.JspServlet
. See "Getting Started in a JServ Environment".
Beginning with the OC4J 9.0.3 implementation, the OC4J JSP container is fully compliant with the JSP 1.2 specification. Most of the new functionality is in the area of custom tag libraries. Here is a summary of new features:
web.xml
file. This enables you to more conveniently manage application and session resources associated with usage of the tag library.
See Chapter 8, "JSP Tag Libraries" for details about these features, and "Overview of Tag Library Changes Between the JSP 1.1 and 1.2 Specifications" for a more detailed summary.
See Chapter 5, "JSP XML Support" for information about these features.
OC4J JSP supports the pageEncoding
attribute of the page
directive. This enables you to specify a character encoding for the page source that is different than the character encoding for the response (specified in the contentType
attribute).
In addition to JSP 1.2 compliance, the OC4J JSP container in Oracle9iAS release 2 (9.0.3) includes the following configurable features.
Also see "Overview of Oracle Value-Added Features".
The following features are new in the OC4J 9.0.3 implementation:
The JSP 1.2 specification mandates translation errors if you have duplicate settings for the same directive attribute within a single JSP translation unit (except for the page
directive import
attribute). These errors may be unwanted or inappropriate, for example, if a page and an included file both set an attribute to the same value (such as language="java"
).
In "JSP Configuration Parameters", see the description of the forgive_dup_dir_attr
parameter.
web.xml
file and TLD files (OC4J or JServ)
Validation of web.xml
is disabled by default but can be enabled. Validation of TLD files is enabled by default but can be disabled.
In "JSP Configuration Parameters", see the descriptions of the xml_validate
and no_tld_xml_validate
parameters.
Use this to automatically import certain Java packages beyond the JSP defaults.
In "JSP Configuration Parameters", see the description of the extra_imports
parameter.
You can specify a directory where tag library JAR files can be placed for sharing across multiple Web applications.
In "JSP Configuration Parameters", see the description of the well_known_taglic_loc
parameter.
You can specify a timeout value for JSP pages, after which a page is removed from memory if it has not been requested again. See "OC4J Configuration Parameters for JSP".
The following features have been supported since the OC4J 9.0.2 implementation:
You have a choice of: 1) running JSP pages without any automatic reloading of classes or recompilation of JSP pages; 2) automatically reloading any classes that are used by the JSP page and have changed; or 3) automatically recompiling any JSP pages that have changed, as well as reloading any classes that have changed.
In "JSP Configuration Parameters", see the description of the main_mode
parameter.
To save time in tag handler creation and garbage collection, you can optionally enable pooling of tag handler instances. They are pooled in application
scope. You can use different settings in different pages, or even in different sections of the same page. See "Disabling or Enabling Runtime or Compile-Time Tag Handler Reuse".
The OC4J configuration parameter jsp-print-null
enables you to print an empty string instead of the default "null" string for null output from a JSP page.
For single-threaded (non-thread-safe) JSP pages, page instances are pooled. There is no switch for this feature--it is always enabled.
The JSP container is provided as a component of OC4J, but is portable to other environments. Because the OC4J JSP container itself emulates certain required servlet features, this portability extends to older servlet environments, in particular the Apache JServ servlet 2.0 environment. (Generally, a servlet 2.3 environment is required in order to support JSP 1.2 compliance.)
The servlet 2.0 specification was limited in that it provided only a single servlet context for each Java virtual machine, instead of a servlet context for each application. The OC4J JSP servlet emulation allows a full application framework in a servlet 2.0 environment, including providing applications with distinct ServletContext
and HttpSession
objects.
Because of this extended functionality, the OC4J JSP container is not limited by the underlying servlet environment.
In addition to JServ 1.1, the OC4J JSP container has been tested with Tomcat 3.1 (servlet 2.2) from the Apache Software Foundation, and JSWDK 1.0 (JavaServer Web Developer's Kit, servlet 2.1) from Sun Microsystems.
Oracle HTTP Server, powered by the Apache Web server, is included with Oracle9i Application Server as the HTTP entry point for Web applications, particularly in a production environment. By default, it is the front-end for all OC4J processes--client requests go through Oracle HTTP Server first.
When the Oracle HTTP Server is used, dynamic content is delivered through various Apache mod components provided either by the Apache Software Foundation or by Oracle. Static content is typically delivered from the file system, which is more efficient in this case. An Apache mod is typically a module of C code, running in the Apache address space, that passes requests to a particular mod-specific processor. The mod software will have been written specifically for use with the particular processor.
Oracle9iAS supplies the mod_oc4j
Apache mod, which is used for communication between the Oracle HTTP Server and OC4J. It routes requests from the Oracle HTTP Server to OC4J processes, and forwards responses from OC4J processes to Web clients.
Communication is through the Apache JServ protocol (AJP). AJP was chosen over HTTP because of a variety of AJP features allowing faster communication, including use of binary format and more efficient processing of message headers.
The following features are provided with mod_oc4j
:
This is accomplished through enhanced use of cookies. Routing information is maintained in the cookie itself to ensure that stateful servlets are always routed to the same OC4J JVM.
A mod_oc4j
module can restart an OC4J instance automatically, if necessary.
Notes:
|
Visual Java programming tools now typically support JSP coding. In particular, Oracle9i JDeveloper supports JSP development and includes the following features:
See "Application Deployment with Oracle9i JDeveloper" for more information about JSP deployment support.
For debugging, JDeveloper can set breakpoints within JSP page source and can follow calls from JSP pages into JavaBeans. This is much more convenient than manual debugging techniques, such as adding print statements within the JSP page to output state into the response stream (for viewing in your browser) or to the server log (through the log()
method of the implicit application
object).
For information about JDeveloper, refer to the JDeveloper online help, or to the following site on the Oracle Technology Network:
http://otn.oracle.com/products/jdev/content.html
For an overview of JSP tag libraries provided with JDeveloper, see the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference.
OC4J value-added features for JSP pages can be grouped into three major categories:
The rest of this section provides feature overviews in each of these areas, plus a brief summary of Oracle support for the JavaServer Pages Standard Tag Library (JSTL). JSTL support is summarized more fully in the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference.
This section provides an overview of extended OC4J JSP features that are implemented through standards-compliant custom tag libraries, custom JavaBeans, and other classes. These features are fully documented in the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference. Here is a summary list:
JspScopeListener
for event-handling
JSP pages generally rely on core Java types in representing scalar values. However, neither of the following 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, you cannot declare them in a jsp:useBean
action, because the wrapper classes do not follow the JavaBean model and do not provide a zero-argument constructor. 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.
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 handles session-based events only. You can integrate the Oracle JspScopeListener
with HttpSessionBindingListener
to handle session-based events, as well as page-based, request-based, and application-based events.
OC4J provides standard JSP XML support as prescribed by the JSP 1.2 specification and described in Chapter 5, "JSP XML Support". In addition, OC4J offers extended support through XML-related custom tags.
There are 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:
OC4J supplies a set of custom JavaBeans for database access. The following beans are provided in the oracle.jsp.dbutil
package:
ConnBean
--Open a database connection. This bean also supports data sources and connection pooling.
ConnCacheBean
--Use the Oracle connection caching implementation for database connections.
DBBean
--Execute a database query.
CursorBean
--This bean provides general DML support for queries; UPDATE
, INSERT
, and DELETE
statements; and stored procedure calls.
OC4J provides a custom SQL tag library for database access. The following tags are provided:
dbOpen
--Open a database connection. This tag also supports data sources and connection pooling.
dbClose
--Close a database connection.
dbQuery
--Execute a database query.
dbCloseQuery
--Close the cursor for a query.
dbNextRow
--Process the rows of a result set.
dbExecute
--Execute any SQL statement (DML or DDL).
dbSetParam
--Set a parameter to bind into a dbQuery
or dbExecute
tag.
dbSetCookie
--Set a cookie.
Although the Sun Microsystems JavaServer Pages Specification, Version 1.2 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 no doubt still 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, flow control, 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>
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.
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, RPC-style mechanism. A client application would access a Web Services Definition Language (WSDL) document, then use the WSDL information to access the operations of a Web service.
The tag library uses Oracle9iAS Web Services and the Oracle implementation of the dynamic invocation API, described in the Oracle9iAS 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.
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.
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.
For using EJBs, there are tags to create a home instance, create an EJB instance, and iterate through a collection of EJBs.
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.
This section provides an overview of Oracle-specific programming extensions supported by the OC4J JSP container:
Dynamic server pages commonly include data extracted from databases. JSP developers typically rely on the standard Java Database Connectivity (JDBC) API or a custom set of database JavaBeans.
SQLJ is a standard syntax for embedding static SQL instructions directly in Java code, greatly simplifying database-access programming. The OC4J JSP container supports SQLJ programming in JSP scriptlets.
SQLJ statements are indicated by the #sql
token. You can trigger the JSP translator to invoke the Oracle SQLJ translator by using the file name extension .sqljsp
for the JSP source code file, or by specifying language="sqlj"
in a page
directive.
For more information, see "JSP Support for Oracle SQLJ".
The OC4J JSP container provides a feature called global includes. You can use this feature to specify one or more files to statically include into JSP pages in (or under) a specified directory, through virtual JSP include
directives. During translation, the JSP container looks for a configuration file, /WEB-INF/ojsp-global-include.xml
, that specifies the included files and the directories for the pages.
This enhancement is particularly useful in migrating applications that had used globals.jsa
or translate_params
functionality in previous Oracle JSP releases. For more information, see "Oracle JSP Global Includes".
The Dynamic Monitoring Service (DMS) adds performance-monitoring features to a number of Oracle9iAS components, including OC4J. The goal of DMS is to provide information about runtime behavior through built-in performance measurements, so that users can diagnose, analyze, and debug any performance problems. DMS provides this information in a package that can be used at any time, including during live deployment. Data are published through HTTP and can be viewed with a browser.
The OC4J JSP container supports DMS features, calculating relevant statistics and providing information to DMS servlets such as the spy servlet and monitoring agent. Statistics include the following (using averages, maximums, and minimums, as applicable):
(Counts of JSP instances are applicable only for single-threaded situations, where isThreadSafe
is set to false
in a page
directive.)
Standard configuration for these servlets is in the OC4J global-web-application.xml
configuration file. Use the Enterprise Manager to access DMS, display DMS information, and, as appropriate, alter DMS configuration.
Also see the Oracle9i Application Server Performance Guide, which contains precise definitions of the JSP metrics and instructions for viewing and analyzing them.
OC4J supports special features for the servlet 2.0 JServ environment. It is highly advisable to migrate to the OC4J servlet 2.3 environment as soon as practical, but in the meantime, be aware of the following:
The referenced sections include information for migration to OC4J.
Faced with Web performance challenges, e-businesses must invest in more cost-effective technologies and services to improve the performance of their Internet sites. Web caching, the caching of both static and dynamic Web content, is a key technology in this area. Benefits of Web caching include performance, scalability, high availability, cost savings, and network traffic reduction.
OC4J provides the following support for Web caching technologies:
The Oracle9iAS Web Cache provides an ESI engine.
The Web Object Cache uses the Oracle9i Application Server Java Object Cache as its default repository.
These features are documented in the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference.
With Oracle9iAS release 2 (9.0.3), the OC4J JSP product supports the JavaServer Pages Standard Tag Library (JSTL), as specified in the Sun Microsystems JavaServer Pages Standard Tag Library, Version 1.0 specification.
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.
Key JSTL features include the following:
The expression language further simplifies the code required to access and manipulate application data, making it possible to avoid request-time attributes as well as scriptlets.
(The term "i18n" refers to an internationalization standard.)
Tag support is broken into four JSTL sublibraries according to these functional areas.
For a more complete summary of JSTL support, you can refer to the Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference. For complete information about JSTL, refer to the specification at the following location:
http://www.jcp.org/aboutJava/communityprocess/first/jsr052/index.html
|
![]() Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|