Oracle® Containers for J2EE Support for JavaServer Pages Developer's Guide 10g (10.1.3.1.0) Part Number B28961-01 |
|
|
View PDF |
This chapter covers basic issues in your JSP environment, including key support files, key OC4J configuration files, and configuration of the Web container. It also discusses initial considerations such as application root functionality, classpath functionality, security issues, and file naming conventions.
The following sections are included in this chapter:
Note: JSP pages will run with any standard browser supporting HTTP 1.0 or higher. The JDK or other Java environment in the user's Web browser is irrelevant, as any Java code in a JSP page is executed within the Web server. |
This section explains your options for configuring the OC4J JSP container, with a focus on configuring the container for JSP development. It includes the following topics:
A number of parameters for configuring the JSP container environment are available in OC4J. Table 3-1 summarizes the supported configuration parameters.
Parameters that are listed in the Application Server Control Console JSP Property column of this table can be set through the JSP Container Properties page of the Oracle Enterprise Manager 10g Application Server Control Console management interface provided with OC4J. See "Setting JSP Parameters in Application Server Control Console" for details.
Parameters that are not exposed through Application Server Control Console can be set directly in the global-web-application.xml
configuration file, which is located in the ORACLE_HOME
/j2ee/home/config
directory by default. The JSP parameters persisted in this file are the default values inherited by all Web modules running within the OC4J server instance.
You can override any of the global settings for a specific Web application by modifying the Web module's web.xml
or orion-web.xml
deployment descriptors. Note that these files must be edited manually; Application Server Control Console does not provide any editing capabilities.
See "Setting JSP Parameters in the XML Configuration Files" for details on setting parameters in the global-web-application.xml
or orion-web.xml
file.
Table 3-1 JSP Environment Configuration Parameters
Application Server Control Console JSP Property | XML Parameter | Description |
---|---|---|
(None) |
|
Set to See the Oracle Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information about the |
(None) |
|
Set to enable JSR-45 debugging support. Valid values are:
|
Debug Mode |
|
Set to When this parameter is |
External Resource for Static Content |
|
Set to The The translator places the resource file into the same directory as generated class files. The resource file name is based on the JSP page name, with the The translation of If there is a lot of static content in a page, this technique will speed translation and may speed execution of the page. For more information, see "Managing Heavy Static Content or Tag Library Usage". |
Extra Import Package List |
|
Use to import additional packages beyond the JSP defaults described in "Packages Imported By Default in OC4J". The Note that in an XML file, the names can be either comma-delimited or space-delimited. Either of the following is valid: <init-param> <param-name>extra_imports</param-name> <param-value>java.util.* java.beans.*</param-value> </init-param> or: <init-param> <param-name>extra_imports</param-name> <param-value>java.util.*,java.beans.*</param-value> </init-param> |
Accept Duplicate Directive Attributes |
|
Set to The |
Validate XML |
|
Set this boolean to Oracle plans to remove this parameter in a future release. This is the only way to implement this behavior in release 10.1.3.1.0. If you implement this behavior, you will have to modify your code when you upgrade to a release where this parameter is removed. |
(None) |
|
Set this Boolean parameter to |
When a JSP Changes |
|
Use to specify whether JSP-generated classes are automatically reloaded or JSP pages are automatically retranslated when changes are made. If enabled, this feature allows new or modified JSPs to be loaded into the OC4J runtime, without requiring the Web application to be redeployed or restarted. See "Configuring Runtime JSP Retranslation and Reloading in OC4J" for additional information. Valid settings are:
|
(None) |
|
Set to Oracle plans to remove this parameter in a future release. This is the only way to implement this behavior in release 10.1.3.1.0. If you implement this behavior, you will have to modify your code when you upgrade to a release where this parameter is removed. |
(None) |
|
Set to The |
Precompile Check |
|
Set this Boolean parameter to If |
Reduce Code Size for Custom Tags |
|
Set this Boolean parameter to |
(None) |
|
Set this Boolean parameter to As an example of a scenario for use of request-time introspection, assume a tag handler returns a generic An additional effect of this flag is to allow a bean to be declared twice, such as in different branches of an <% if (cond) { %> <jsp:useBean id="foo" class="pkgA.Foo1" /> <% } else { %> <jsp:useBean id="foo" class="pkgA.Foo2" /> <% } %> |
(None) |
|
Set this Boolean parameter to The |
Generate Static Text as Chars |
|
Set this Boolean parameter to Enable this flag if your application requires the ability to change the character encoding dynamically during runtime, such as in the following example: <% response.setContentType("text/html; charset=UTF-8"); %> The |
(None) |
|
Set this flag to The |
Tags Reuse Default |
|
Use this parameter to specify the mode for tag handler reuse, also known as tag pooling.
|
JSP Page Timeout |
|
Specify an integer value greater than |
Persistent TLD Caching |
|
OC4J provides a persistent caching feature for TLD files, with a global cache for TLD files in well-known tag library locations, as well as an application-level cache for any application that uses TLD caching. See "Enabling the TLD Caching Feature" for more information. By default, applications inherit the TLD caching value set at the global Web application level. However, if TLD caching is set at the application level, this value will override the global setting.
Note that the value of this parameter has implications on the ability to set multiple well-known tag libraries, as described in the Tag Lib Locations ( |
Tag Libraries Location List |
|
As an extension of standard JSP "well-known URI" functionality described in the JSP specification, the OC4J JSP container supports the use of one or more well-known tag libraries - directories in which you can place tag library JAR files to allow the libraries to be shared across multiple Web applications. See "Specifying Well-Known Tag Library Locations" for more information. If TLD caching is disabled ( Note that the Note that tag libraries placed in a well-known directory must be packaged in a JAR file. |
(None) |
|
Set to If you must map the *.jsp extension to another servlet, set this parameter to |
Oracle Enterprise Manager 10g Application Server Control Console is the administration console for an Oracle Application Server instance. It is installed by default with OC4J.
After logging in, access the JSP Container Properties page through Administration->JSP Properties links.
See the following for instructions on accessing the console:
Accessing Application Server Control Console in Standalone OC4J
Accessing Application Server Control Console in Oracle Application Server
The Application Server Control Console is installed and configured automatically when you install the OC4J software. It is started by default when OC4J is started.
The console is accessed through the default
Web site, which is configured to listen for HTTP requests on port 8888. To access the console, simply type the following URL in a Web browser:
http://hostname:8888/em
The Application Server Control Console is installed and configured automatically when you install OC4J using the Oracle Universal Installer.
The console is started with all other installed Oracle Application Server components using the OPMN command-line tool, opmnctl
, which is installed in the ORACLE_HOME
/opmn/bin
directory on each server node. Start all installed components by issuing the following command:
cd ORACLE_HOME/opmn/bin
opmnctl startall
In a typical Oracle Application Server installation, all Web applications, including Application Server Control Console, are accessed through Oracle HTTP Server (OHS). Use the following URL to access the console:
http://ohs_host_address:port/em
ohs_host_address
is the address of the OHS host machine.; for example, server07.company.com
port
is an HTTP listener port assigned to OHS by OPMN. Run the following opmnctl
command on the OHS host machine to get the list of assigned listener ports from OPMN:
opmnctl status -l
Supply the port designated as http1
in the OPMN status output as the value for port
:
HTTP_Server | HTTP_Server | 6412 | Alive | 1970872013 | 1
6396 | 0:48:01 | https1:4443,http2:722,http1:7779
In an OC4J development environment, you can set JSP configuration parameters directly in the global and module-specific configuration files.
For more information about global-web-application.xml
and orion-web.xml
, see the Oracle Containers for J2EE Servlet Developer's Guide.
An instance of the front-end servlet class - oracle.jsp.runtimev2.JspServlet
- is created for each Web module instantiated within an OC4J instance. Note that this servlet class is the only servlet supported by OC4J.
The default parameters used to initialize each servlet instance are specified in <init-param>
subelements of the <servlet>
element within the global-web-application.xml
configuration file.
Note that you can override any of the default servlet parameters at the Web application level by specifying corresponding <init-param>
elements in the J2EE standard web.xml
deployment descriptor installed with the Web module. The default location for this file is the ORACLE_HOME
/home/j2ee/
appName
/
webModuleName
/WEB-INF
directory.
The following example illustrates how to set <init-param>
elements containing servlet initialization parameters within the <servlet>
element for the JSP front-end servlet. This sample enables the precompile_check
flag, sets the main_mode
flag to run without checking timestamps, and runs the Java compiler in verbose mode.
<servlet> <servlet-name>jsp</servlet-name> <servlet-class>oracle.jsp.runtimev2.JspServlet</servlet-class> <init-param> <param-name>precompile_check</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>main_mode</param-name> <param-value>justrun</param-value> </init-param> <init-param> <param-name>javaccmd</param-name> <param-value>javac -verbose</param-value> </init-param> </servlet>
Note: Thejavaccmd parameter is deprecated in Oracle Containers for J2EE 10g (10.1.3.1.0). |
The parameters that control such functionality as JSP timeout and whether TLD caching is enabled are set as attributes of the root <orion-web-app>
element in either global-web-application.xml
or a Web module's orion-web.xml
file. As with servlet initialization parameters, attributes set in orion-web.xml
override the corresponding global definition in global-web-application.xml
. The file for a deployed Web module is located in the ORACLE_HOME
/j2ee/home/application-deployments/
appName
/
webModuleName
directory by default.
The following example shows how to set attributes of the root <orion-web-app>
element within an XML file:
<orion-web-app development="false" jsp-timeout="30" ... > ... </orion-web-app>
<ojsp-init>
In the orion-web.xml
file, you can use the <ojsp-init>
element to set the JSP configuration parameters that Table 3-2 lists.
Table 3-2 JSP Servlet Configuration Parameters
<ojsp-init> Attribute | Equivalent JSP Servlet <init-param> | ojspc Command-Line Option |
---|---|---|
debug-mode |
debug_mode |
n/a |
iso-8859-1-convert |
iso-8859-1-convert |
n/a |
jsr45-debug |
debug |
-debug |
main-mode |
main_mode |
n/a |
precompile-check |
precompile_check |
n/a |
reduce-tag-code |
reduce_tag_code |
-reduceTagCode |
req-time-introspection |
req_time_instrospection |
-reqTimeIntrospection |
static-text-in-chars |
static-text-in-chars |
-staticTextInChars |
tags-reuse |
tags_reuse_default |
-tagReuse |
For descriptions of these parameters, see "Summary of JSP Configuration Parameters".
If you specify <ojsp-init>
in the orion-web.xml
file for a Web application, the values of these attributes, including default values, override the values of any corresponding JSP configuration parameters specified in <init-param>
elements in the web.xml
deployment descriptor installed with the Web module. Any corresponding command-line options of the ojspc
pretranslation utility override the <ojsp-init>
attributes as well as any corresponding settings in web.xml
.
Note: You cannot use an<ojsp-init> element in global-web-application.xml . |
<ojsp-config>
The Oracle-specific <ojsp-config>
element is defined in the orion-web.xml
file. The semantics of the <ojsp-config>
is parallel to web.xml
file <jsp-config>
element that was introduced in JSP 2.0.
The <default-buffer-size>
property specifies the default buffer size to be used by a JSP writer object for the set of JSPs governed by the <url-pattern>
. Currently (release 10.1.3.1) <default-buffer-size>
is the only setting you can make in <ojsp-config>
. The <default-buffer-size>
setting is not available in the <jsp-config>
element.
You can override this <default-buffer-size> setting for an individual JSP page by using the page directive buffer
attribute.
Here is an example of using the page directive to set buffer size:
<%@ page buffer="7kb" %>
Here is an example of the syntax of the <ojsp-config>
element in the orion-web.xml
file:
<ojsp-config> <ojsp-property-group> <url-pattern> ...</url-pattern> <default-buffer-size>..</default-buffer-size> </ojsp-property-group> .... multiple <ojsp-property-group> can exist </ojsp-config>
The Java compiler can be invoked to execute in-process - within in the same JVM process as OC4J - or out-of-process, within in a separate JVM process.
By default, OC4J uses out-of-process compilation, and the compiler is invoked as a separate executable. The default compiler used is javac
from the Sun Microsystems JDK.
You can configure OC4J to use a different compiler, or to compile in-process, by adding a <java-compiler>
element with desired settings to the OC4J server.xml
file. See the Oracle Containers for J2EE Configuration and Administration Guide for details.
OC4J allows new JavaServer Pages (JSPs) to be added to an actively running Web module - as well as existing JSPs to be modified - without requiring an application redeployment or restart.
To use this feature, simply drop a new or updated JSP into the appropriate directory within the exploded WAR file structure in the OC4J instance, which is ORACLE_HOME
/j2ee/
instance
/applications/
appName
/
webModuleName
/
. OC4J will translate the page and load (or reload) it into the runtime.
This feature is controlled by the main_mode
servlet initialization parameter. Possible settings are:
recompile
(default) to retranslate JSP pages that have changed
reload
to reload classes that were generated by the Web container and have changed (such as page implementation classes)
justrun
to run without any retranslation or reloading, which may provide optimal performance in production environments
See "Summary of JSP Configuration Parameters" for additional information on the main_mode
parameter.
Notes:
|
For information about classloading behavior at the servlet layer, see the Oracle Containers for J2EE Servlet Developer's Guide.
This section summarizes JAR and ZIP files that are used by the Web container or JSP applications. These files are installed on your system and into your classpath with OC4J.
ojsputil.jar
: classes for tag libraries and utilities provided with OC4J
xmlparserv2.jar
: for XML parsing; required for the web.xml
deployment descriptor and any tag library descriptor files and XML-related tag functionality
ojdbc14.jar
/ classes12.jar
/ classes111.jar
: for the Oracle JDBC drivers (for JDK 1.4, 1.2 or higher, respectively)
runtime12.jar
/ runtime12ee.jar
/ runtime11.jar
/ runtime.jar
/ runtime-nonoracle.jar
: for the Oracle SQLJ runtime (for JDK 1.2.x or higher with Oracle9i or higher JDBC, JDK 1.2.x or higher enterprise edition with Oracle9i or higher JDBC, or any JDK environment with non-Oracle JDBC drivers, respectively)
jndi.jar
: for JNDI service for lookup of resources such as JDBC data sources and Enterprise JavaBeans
There are also files relating to particular areas, such as particular tag libraries. These include the following: