Oracle® Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide
10g Release 2 (10.1.2) B14014-02 |
|
Previous |
Next |
The JSP container provided with Oracle Application Server Containers for J2EE (OC4J) in the Oracle Application Server is a complete implementation of the JSP 1.2 specification. This functionality depends upon servlet 2.3 functionality, and the OC4J servlet container is a complete implementation of the servlet 2.3 specification.
This chapter provides overviews of the Oracle Application Server, OC4J, the OC4J JSP implementation and features, and custom tag libraries and utilities that are also supplied (documented in the Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference).
The following sections are included:
The following sections provide a brief overview of the Oracle Application Server, its J2EE environment, its JSP implementation, and its Web server:
Overview of the JSP Implementation in OC4J
Note: Users of earlier Oracle Application Server releases can refer to Oracle Application Server Upgrade and Compatibility Guide for information about issues in migrating to the current release. |
Oracle 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 services, and management and security. For performance, scalability, and dependability, there are also clustering and load-balancing features.
To deliver this range of content and services, the Oracle Application Server incorporates many components, including the Oracle HTTP Server, Oracle Application Server Web Cache, Oracle Application Server Web Services, Oracle Application Server Portal, Oracle Application Server Wireless, and business logic runtime environments that support Enterprise JavaBeans, stored procedures, and Oracle Application Development Framework (Oracle ADF) Business Components.
For its Java environment, Oracle Application Server provides the Oracle Application Server Containers for J2EE (OC4J), a J2EE 1.3-compliant set of containers and services. This includes the JSP container described in this manual, a servlet container, and an EJB container.
For administration, you can fully manage and configure Oracle Application Server and OC4J using the HTML-based Oracle Enterprise Manager 10g. This includes full support for managing clustering, configuration, and deployment.
Oracle HTTP Server, powered by the Apache Web server, is included with Oracle 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.
Oracle Application Server 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
:
Load balancing capabilities across many back-end OC4J clusters
Stateless session routing of stateful servlets
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.
Note: Oracle HTTP Server is not relevant for an OC4J standalone environment (typically used only during development). See "OC4J Standalone". |
The following sections provide an overview of features of OC4J, the J2EE component of the Oracle Application Server:
OC4J is a high-performance, J2EE-compliant set of containers and services providing a scalable and reliable server infrastructure. In Oracle Application Server 10g Release 2 (10.1.2), OC4J complies with the J2EE 1.3 specification.
For developer convenience, OC4J has been integrated with Oracle JDeveloper and other development tools, and can run in a standalone mode separate from Oracle Application Server during the development process.
Java applications built with any development tool can be deployed to OC4J, which supports standard EAR or WAR file deployment. You can debug applications deployed to OC4J through standard Java profiling and debugging facilities.
For security, OC4J supports Secure Socket Layer (SSL) and HTTPS functionality.
Note: Each OC4J instance runs in a single Java virtual machine. |
OC4J supports the following Java and J2EE services:
J2EE Connector Architecture (JCA): JCA defines a standard architecture for connecting J2EE platforms to heterogeneous enterprise information systems such as ERP systems, mainframe transaction processing, database systems, and legacy applications.
Java Transaction API (JTA) and two-phase commits: JTA allows simultaneous updates to multiple resources in a single, coordinated transaction.
Java Message Service (JMS) integration: This integration allows compatibility between the Oracle JMS implementation and those of other JMS providers.
Java Naming and Directory Interface (JNDI): JNDI associates names with resources for lookup purposes.
Java Authentication and Authorization Service (JAAS): The Oracle implementation of JAAS and the Java2 security model provides complete support for development and deployment of secure applications and for fine-grained authorization and access control.
JDBC data sources: This is the standard mechanism for connecting to a database.
See the Oracle Application Server Containers for J2EE Services Guide for information.
The OC4J 10.1.2 implementation supplies the following J2EE containers:
A JSP container complying with the Sun JSP 1.2 specification
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".
A servlet container complying with the servlet 2.3 specification (with key features described immediately below)
An EJB container complying with the EJB 2.0 specification (with key features described below)
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.
Note: Servlet 2.3 compliance is required in order to support JSP 1.2 compliance. |
The OC4J servlet container supports the following key features:
SSL and HTTPS: In Oracle Application Server, OC4J supports SSL (Secure Socket Layer) communication between Oracle HTTP Server and OC4J, using secure AJP. In addition, OC4J standalone supports SSL communication directly between a client and OC4J, using HTTPS.
Integration with SSO and Oracle Internet Directory: This is through the Oracle JAAS implementation.
Stateful failover and cluster deployment: For a distributable application, session state is replicated to alternate OC4J servers so that state is not lost in the event of failover.
Servlet filtering: This allows transformation of the content of an HTTP request or response, and modification of header information.
Application-level and session-level event listeners: This feature allows greater control over interaction with servlet context and HTTP session objects and, therefore, greater efficiency in managing resources that the application uses.
See the Oracle Application Server Containers for J2EE Servlet Developer's Guide for information.
The OC4J EJB container supports the following:
Session beans: A session bean is used for task-oriented requests. You can define a session bean as stateless or stateful. Stateless session beans cannot maintain state information across calls, while stateful session beans can maintain state across calls.
Entity beans: An entity bean represents data. It can use the container to maintain the data persistently, which is referred to as container-managed persistence (CMP), or it can use the bean implementation to manage the data, which is referred to as bean-managed persistence (BMP).
Message-driven beans (MDB): A message-driven bean is used to receive JMS messages from a queue or topic. It can then invoke other EJBs to process the JMS message.
EJB support in OC4J also includes these features:
Clustering for session and entity beans
Enhanced entity bean concurrency models to support concurrent access from multiple clients
Extended locking models for entity beans (optimistic locking mode / pessimistic locking mode / read-only mode)
Active Components for Java (AC4J), to provide a standards-based infrastructure for coordinating long-running business transactions
See the Oracle Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide for information.
In a production environment, it is typical to use OC4J inside a complete Oracle Application Server environment, including the Oracle HTTP Server (as described in "Oracle HTTP Server and mod_oc4j"), OracleAS 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 at the following location:
http://www.oracle.com/technology/tech/java/oc4j
When using OC4J standalone, you can use its own HTTP Web listener through port 8888. For information about OC4J standalone, see the Oracle Application Server Containers for J2EE Stand Alone User's Guide (downloadable with OC4J_extended.zip) and the Oracle Application Server Containers for J2EE Servlet Developer's Guide.
Note: To use OC4J standalone, you must have a supported version of the Sun Microsystems JDK installed. A JDK is not provided with the OC4J standalone product. |
The JSP container in Oracle Application Server 10g Release 2 (10.1.2) is compliant with the JSP 1.2 specification.
In general, a JSP 1.2 environment requires a servlet 2.3 environment, such as the OC4J servlet container. The OC4J JSP implementation, however, also supports running on 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.
These features are discussed in the following sections:
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. 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, use the old front-end servlet, oracle.jsp.JspServlet
.
In the OC4J 10.1.2 implementation, the OC4J JSP container is fully compliant with the JSP 1.2 specification. Most functionality introduced in this specification is in the area of custom tag libraries.
Tag library features:
There is a tag handler interface that allows iteration through a tag body without having to maintain and access a body content object.
You can create a tag-library-validator class and associate it with a tag library. A validator instance will check any JSP page that uses the library, to verify that it meets whatever constraints you desire.
For convenience, you can declare servlet event listeners in a tag library descriptor file instead of in the web.xml
file. This enables you to more conveniently manage application and session resources associated with usage of the tag library.
You can package multiple tag libraries and their TLD files inside a single JAR file.
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.
XML features:
The OC4J JSP container previously supported a standard XML-alternative syntax, but this is replaced with newer technology according to the current JSP specification.
The OC4J JSP container generates an XML view of every translated page, which is a mapping to an XML document that describes the page. This view is available for use by tag-library-validator classes.
See Chapter 5, "JSP XML Support" for information about these features.
Character encoding features:
The OC4J JSP implementation 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 Oracle Application Server 10g Release 2 (10.1.2) includes the following notable features.
Also see "Overview of Oracle Value-Added Features".
The following have been supported since the OC4J 9.0.3 implementation:
Mode switch to avoid JSP translation errors if you have duplicate settings for the same directive attribute within a single JSP translation unit
The JSP 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 Parameter Descriptions", see the description of the forgive_dup_dir_attr
parameter.
Separate mode switches for XML validation of web.xml
file and TLD files
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 Parameter Descriptions", see the descriptions of the xml_validate
and no_tld_xml_validate
parameters.
Mode flag for extra imports
Use this to automatically import certain Java packages beyond the JSP defaults.
In "JSP Configuration Parameter Descriptions", see the description of the extra_imports
parameter.
"Well-known" location for sharing tag libraries
You can specify a directory where tag library JAR files can be placed for sharing across multiple Web applications.
In "JSP Configuration Parameter Descriptions", see the description of the well_known_taglib_loc
parameter.
Configurable JSP timeout
You can specify a timeout value for JSP pages, after which a page is removed from memory if it has not been requested again. In "JSP-Related OC4J Configuration Parameter Descriptions", see the description of the jsp-timeout
parameter.
The following features have been supported since the OC4J 9.0.2 implementation:
Mode switch for automatic page retranslation and reloading
You have a choice of: 1) running JSP pages without any automatic reloading or retranslation of JSP pages; 2) automatically reloading any page implementation classes (but not JavaBeans or other dependency classes); or 3) automatically retranslating any JSP pages that have changed.
In "JSP Configuration Parameter Descriptions", see the description of the main_mode
parameter.
Tag handler instance pooling
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".
Output mode for null output
You can print an empty string instead of the default "null" string for null output from a JSP page.
In "JSP-Related OC4J Configuration Parameter Descriptions", see the description of the jsp-print-null
parameter.
Single-threaded-model JSP instance pooling
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. (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 servlet context and HTTP session objects.
Because of this extended functionality, the OC4J JSP container is not limited by the underlying servlet environment.
Visual Java programming tools now typically support JSP coding. In particular, Oracle JDeveloper supports JSP development and includes the following features:
Integration of the OC4J JSP container to support the full application development cycle: editing, debugging, and running JSP pages
Debugging of deployed JSP pages
An extensive set of data-enabled and Web-enabled JavaBeans, known as JDeveloper Web beans
The JSP Element Wizard, which offers a convenient way to add predefined Web beans to a page
Support for incorporating custom JavaBeans
A deployment option for JSP applications that rely on Oracle ADF Business Components, offered with JDeveloper
See "Application Deployment with Oracle 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://www.oracle.com/technology/products/jdev/content.html
(You will need an Oracle Technology Network membership, which is free of charge.) For an overview of JSP tag libraries provided with JDeveloper, see the Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference.
Note: Other key IDE vendors have built plug-in modules that allow seamless integration with OC4J. This provides developers with the capability to build, deploy, and debug J2EE applications running on OC4J directly from within the IDE. You can refer to the following Web site for more information:
|
OC4J value-added features for JSP pages can be grouped into three major categories:
Features implemented through custom tag libraries, custom JavaBeans, or custom classes that are generally portable to other JSP environments
Features that are Oracle-specific
Features supporting caching technologies
The rest of this section provides feature summaries and overviews in 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 Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference.
This section lists extended OC4J JSP features that are implemented through standards-compliant custom tag libraries, custom JavaBeans, and other classes. These features are documented in the Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference:
Extended types implemented as JavaBeans that can have a specified scope
JspScopeListener
for event-handling
Integration with XML and XSL
Data-access tag library (sometimes referred to as "SQL tags") and JavaBeans
The JSP Markup Language (JML) custom tag library, which reduces the level of Java proficiency required for JSP development
Personalization tags, for use with Oracle Application Server Personalization
Web services tag library
Tag libraries and JavaBeans for uploading files, downloading files, and sending e-mail from within an application
EJB tag library
Additional utility tags, such as for displaying dates and currency amounts appropriately for a specified locale
Important: TheJspScopeListener and JML tag library are deprecated in the OC4J 10.1.2 implementation and will be desupported in future implementations.
|
Note: See "Overview of Tags and API for Caching Support" for an overview of additional tag libraries for caching. |
This section provides an overview of Oracle-specific programming extensions supported by the OC4J JSP container:
Global includes, a mechanism to automatically statically include a file or files in multiple pages
Dynamic Monitoring Service (DMS) support for performance measurements
Enhanced application framework and globalization support for servlet 2.0 environments
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".
DMS adds performance-monitoring features to a number of Oracle Application Server 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). Times are in milliseconds.
Processing time of HTTP request
Processing time of JSP service method
Number of JSP instances created or available
Number of active JSP instances
(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 application.xml
and default-web-site.xml
configuration file. Use the Enterprise Manager to access DMS, display DMS information, and, if appropriate, alter DMS configuration.
Also see the Oracle Application Server Performance Guide, which contains precise definitions of the JSP metrics and detailed instructions for viewing and analyzing them.
OC4J supports special features for a servlet 2.0 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:
An enhanced application framework for servlet 2.0 environments
Extended globalization support for servlet 2.0 environments
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 JESI tag library for Edge Side Includes (ESI), an XML-style markup language that allows dynamic content assembly away from the Web server
The OracleAS Web Cache provides an ESI engine.
A tag library and servlet API for the Web Object Cache, an application-level cache that is embedded and maintained within a Java Web application
The Web Object Cache uses the Oracle Application Server Java Object Cache as its default repository.
These features are documented in the Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference.
With Oracle Application Server 10g Release 2 (10.1.2), 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:
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 attributes as well as scriptlets.
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 organized into four JSTL sublibraries according to these functional areas.
For a more complete summary of JSTL support, you can refer to the Oracle Application Server 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
Note: The custom JML, XML, and data-access (SQL) tag libraries provided with OC4J pre-date JSTL and have areas of duplicate functionality. Going forward, for standards compliance, it is generally advisable to use JSTL instead of the custom libraries. |