Skip Headers

Oracle Application Server 10g Migrating from WebLogic
10g (9.0.4)

Part Number B10425-01
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

4
Migrating JSP Pages

This chapter provides the information you need to migrate JavaServer pages from WebLogic Server to Oracle Application Server. It covers the migration of simple JSP pages, custom JSP tag libraries, and WebLogic custom tags.

This chapter contains these topics:

Introduction

Migrating JSP pages from WebLogic Server to Oracle Application Server is straight forward and requires little or no code changes.

Both application servers are fully compliant with Sun Microsystem's JavaServer Page specifications, version 1.1 and 1.2. All JSP pages written to the standard specification will work correctly and require minimal migration effort.

The primary tasks involved in migrating JSP pages to a new environment are configuration and deployment. The use of proprietary extensions and tag libraries will require additional tasks and complicate the migration effort.

The tasks involved in migrating JSP pages also depend on how the JSP pages have been packaged and deployed. JSP pages can be deployed as a simple JSP page, as a web application packaged with other resources in a standard directory structure (WAR file), or as a enterprise application archive (EAR) file. The migration of web applications in exploded directory format and WAR files is addressed in Chapter 3, "Migrating Java Servlets".

Differences Between WebLogic Server and Oracle Application Server JSP Implementations

Since both WebLogic Server and Oracle Application Server Containers for J2EE (OC4J) have implemented the same versions of the Java Server Pages specifications, there are no differences between the two in the core JSP specification areas. There are differences in areas outside the core specifications. These are listed in Table 4-1.

Table 4-1 JSP feature comparison

Feature Oracle Application Server WebLogic Server

JSP Version Support

1.2

1.2

Basic JSP Tag Libraries

Yes

Yes

Advanced JSP Tag Libraries

Yes

No

JSP Source Level Debugging

Yes

No

ASP to JSP Source Level Conversion

Yes

No

Each vendor provides their own custom JSP tags. WebLogic Server provides four specialized JSP tags that you can use in your JSP pages. OC4J also provides various JSP tags - Oracle JSP Markup Language (JML) Custom Tag Library, tags for XML and XSL integration, and several JSP utility tags. A comprehensive discussion of these tags can be found in Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference.

OC4J JSP Features

Oracle Application Server provides one of the fastest JSP engines on the market. Further, it also provides several value-added features and enhancements such as support for globalization and SQLJ. If you are familiar with Oracle9iAS 1.0.2.2, the first release of Oracle Application Server to include OC4J, there were two JSP containers: a container developed by Oracle and formerly known as OracleJSP and a container licensed from Ironflare AB and formerly known as the "Orion JSP container".

In Oracle Application Server, these have been integrated into a single JSP container, referred to as the "OC4J JSP container". This new container offers the best features of both previous versions, runs efficiently as a servlet in the OC4J servlet container, and is well integrated with other OC4J containers. The integrated container primarily consists of the OracleJSP translator and the Orion container runtime running with a new simplified dispatcher and the OC4J 1.0.2.2 core runtime classes. The result is one of the fastest JSP engines on the market with additional functionality over the standard JSP specifications.

OC4J JSP provides extended functionality through custom tag libraries and custom JavaBeans and classes that are generally portable to other JSP environments:

The OC4J JSP container also offers several important features such as the ability to switch modes for automatic page recompilation and class reloading, JSP instance pooling, and tag handler instance pooling.

Edge Side Includes for Java (JESI) Tags

OC4J provides fine-grained control allowing developers to cache fragments of JSP pages down to each individual tag - these can be cached in OracleAS Web Cache and are automatically invalidated and refreshed when a JSP changes. The technology behind this is Edge Side Includes (ESI), a W3C standard XML schema/markup language that allows dynamic content to be cached in a Web Cache or to be assembled in an edge network. By caching this dynamic content, it reduces the need to execute JSPs or Servlets, thereby improving performance, off loading the application servers, and reducing latency. JESI (JSP to ESI) tags are layered on top of an Edge Side Includes (ESI) framework to provide ESI caching functionality in a JSP application. JESI tags enable the user to break down dynamic content of JSP pages into cacheable components or fragments.

Web Object Cache Tags

The Web Object Cache is an Oracle Application Server feature that allows Web applications written in Java to capture, store, reuse, post-process, and maintain the partial and intermediate results generated by JSPs or Servlets. For programming interfaces, it provides a tag library (for use in JSP pages) and a Java API (for use in Servlets). Cached objects might consist of HTML or XML fragments, XML DOM objects, or Java serializable objects. By caching these objects in memory, various operations can be carried out on the cached objects including:

Oracle JDeveloper and OC4J JSP Container

Oracle JDeveloper is integrated with the OC4J JSP container to support the full JSP application development cycle - editing, source-level debugging, and running JSP pages. It also provides an extensive set of data-enabled and web-enabled JavaBeans, known as JDeveloper web beans and a JSP element wizard which offers a convenient way to add predefined web beans to a page. JDeveloper also provides a distinct feature that is very popular with developers. It allows you to 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 display on browser or to the server log.

Migrating a Simple JSP Page

JSP pages do not require specific mappings as do HTTP servlets. To deploy a simple JSP page, you can copy the JSP page and any files required by the JSP page to the appropriate directories. No additional registrations are required.


Note:

Application Server Control should be used to deploy any type of applications including JSPs. But for the purpose of illustration, the JSP files in the following example are copied manually without using Application Server Control.


The deployment process has been simplified in OC4J by providing a J2EE web application and various configuration files by default.

To determine the effort involved in migrating JSP pages, we selected and migrated example JSP pages provided with WebLogic Server. We chose examples that did not use proprietary extensions.

Table 4-2 presents the typical process for migrating a simple JSP page from WebLogic Server to OC4J.

Table 4-2 Migrating a Simple JSP Page  
Step Description Process

1

Start an instance of OC4J, if none are currently running.

Go to http://<hostname>:1810 and select the OC4J instance you want to start (<hostname> is the name of your Oracle Application Server host). Or, use the following dcmctl command:

dcmctl start -i <appsvr_instance_name> -ct 
oc4j -co home

where <appsvr_instance_name> is the name of your Oracle Application Server instance.

2

Copy the JSP page to the appropriate directory

Copy HelloWorld.jsp from its directory in your WebLogic Server installation to the appropriate directory in Oracle Application Server as follows:

In UNIX, from:

<BEA_HOME>/weblogic700/samples/server/src/
examples/jsp/

to:

<ORACLE_HOME>/j2ee/home/default-web-app/

In Windows, from:

<BEA_HOME>\weblogic700\samples\server\src\
examples\jsp\

to:

<ORACLE_HOME>\j2ee\home\default-web-app\

3

Copy any files required by the JSP page

Copy BEA_Button_Final_web.gif from its directory in your WebLogic Server installation to the appropriate directory in Oracle Application Server as follows:

In UNIX, from:

<BEA_HOME>/weblogic700/samples/
server/src/examples/images/

to:

<ORACLE_HOME>/j2ee/home/default-web-app/
images/

In Windows, from:

<BEA_HOME>\weblogic700\samples\server\src\
examples\images\

to:

<ORACLE_HOME>\j2ee\home\default-web-app\
images\

Note: You may have to create the images directory

4

Request the JSP page from your web browser

From a web browser, request the JSP page through the URL:

http://<hostname>:7777/j2ee/HelloWorld.jsp

where <hostname> is the Oracle Application Server host you copied the JSP file to.

See Also:

Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide and Oracle Application Server Containers for J2EE User's Guide for detailed information on configuring and deploying JSP pages.

Migrating a Custom JSP Tag Library

WebLogic Server and OC4J provide the ability to create and use custom JSP tags. The process used to deploy a custom JSP tag library is similar for both WebLogic Server and OC4J.

Tag libraries can be packaged and deployed as part of a web application, and are declared in a specific section of the web application deployment descriptor.

To determine the effort involved in migrating custom JSP tag libraries, we selected and migrated example JSP pages provided with WebLogic Server. We chose examples that did not use proprietary extensions.

Table 4-3 presents the typical process for migrating a JSP page that utilizes a custom JSP tag library from WebLogic Server to OC4J.

Table 4-3 Migrating a Custom JSP Tag Library  
Step Description Process

1

Copy the tag library file to the appropriate directory

Copy counter.tld from

UNIX:
<BEA_HOME>/weblogic700/samples/
server/src/examples/jsp/tagext/
counter/

Windows:
<BEA_HOME>\weblogic700\samples\
server\src\examples\jsp\tagext\
counter\

of your WebLogic Server installation to the following directory in your OC4J installation:

UNIX:
<ORACLE_HOME>/j2ee/home/
default-web-app/WEB-INF/

Windows:
<ORACLE_HOME>\j2ee\home\
default-web-app\WEB-INF\

2

Copy the JSP file that uses the tag library to the appropriate directory

Copy pagehits.jsp from

UNIX:
<BEA_HOME>/weblogic700/samples/
server/src/examples/jsp/tagext/
counter/

Windows:
<BEA_HOME>\weblogic700\samples\
server\src\examples\jsp\tagext\
counter\

of your WebLogic Server installation to the following directory in your OC4J installation:

UNIX:
<ORACLE_HOME>/j2ee/home/
default-web-app/

Windows:
<ORACLE_HOME>\j2ee\home\
default-web-app
\

3

Copy any class files required by the tag library and used by the JSP file to the appropriate directory

Copy Count.class, Display.class, and Increment.class from

UNIX:
<BEA_HOME>/weblogic700/samples/server/
config/examples/applications/
examplesWebApp/WEB-INF/classes/
examples/jsp/tagext/counter/

Windows:
<BEA_HOME>\weblogic700\samples\server\
config\examples\applications\
examplesWebApp\WEB-INF\classes\
examples\jsp\tagext\counter\

of your WebLogic Server installation to the following directory in your OC4J installation:

UNIX:
<ORACLE_HOME>/j2ee/home/
default-web-app/WEB-INF/
classes/examples/jsp/tagext/counter/

Windows:
<ORACLE_HOME>\j2ee\home\
default-web-app\WEB-INF\
classes\examples\jsp\tagext\counter\

of your OC4J installation

Note that these .class files provided with the WebLogic server installation belong to a package called examples.jsp.tagext.counter. You may need to create the examples/jsp/tagext/counter/ directory (or Windows equivalent).

4

Copy image files used by the JSP file

Copy the directory containing the image files from

UNIX:
<BEA_HOME>/weblogic700/samples/server/
src/examples/jsp/tagext/counter/
images/numbers/

Windows:
<BEA_HOME>\weblogic700\samples\server\
src\examples\jsp\tagext\counter\
images\numbers\

of the WebLogic Server installation to the following directory in your OC4J installation:

UNIX:
<ORACLE_HOME>/j2ee/home/
default-web-app/images/numbers/

Windows:
<ORACLE_HOME>\j2ee\home\
default-web-app\images\numbers\

Note that you may have to create the images/numbers (or Windows equivalent) directory

5

Modify the appropriate web application deployment descriptor and save the changes

Add the directive entry below to the web.xml file located in the following directory of your OC4J installation:

UNIX:
<ORACLE_HOME>/j2ee/home/
default-web-app/WEB-INF/

Windows:
<ORACLE_HOME>\j2ee\home\
default-web-app\WEB-INF\

Directive entry (<taglib> is a child element of <web-app>):

<taglib>
  <taglib-uri>
   counter
  </taglib-uri>
  <taglib-location>
   /WEB-INF/counter.tld
  </taglib-location>
</taglib>

6

Restart or start the OC4J instance, if it is not currently running.

Go to http://<hostname>:1810 and restart/start the home OC4J instance. Or, use the following dcmctl command:

dcmctl restart|start -i <appsvr_instance_
name> -ct oc4j -co home

where <appsvr_instance_name> and <hostname> are the names of your Oracle Application Server instance and host respectively.

7

Request the JSP file from your web browser

From your web browser, access the URL

http://<hostname>:7777/j2ee/
pagehits.jsp

where <hostname> is the Oracle Application Server host you copied the files to.

See Also:

  • Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide for detailed information on configuring and deploying JSP pages.

  • Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on custom JSP tag libraries.

Migrating from WebLogic Custom Tags

If WebLogic custom tags are used extensively throughout your web application, then the best migration option is to use the WebLogic tag library by deploying it on OC4J. This option was discussed in the previous section, "Migrating a Custom JSP Tag Library". You can then migrate to the OC4J JSP tags if required.

If WebLogic custom tags are used sparingly throughout your web application, then the best migration option is to modify the JSP pages to use the OC4J JSP tag library. This option is discussed below.

WebLogic Server provides three specialized JSP tags for use in JSP pages. They are cache, process, and repeat.

WebLogic Server cache Tag

OC4J provides a superset of the WebLogic Server cache tag in the form of Web Object Cache Tags. These tags provide additional functionality over the WebLogic cache tag. Further, the Web Object Cache Tags of OC4J are well integrated with other tag libraries such as the XML tag library. For example, the cacheXMLObj tag is well integrated with OC4J's XML tags.

One feature which does not have direct functionality mapping is "async". However, Edge Side Includes (ESI) and Edge Side Includes for Java (JESI) can provide similar functionality to it.

See Also:

Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on Web Object Cache tags and JESI tags.

WebLogic Server process Tag

OC4J does not have an exact equivalent for the process tag. The closest option is to use the jml:useForm and jml:if tags. from Oracle's JSP Markup Language (JML).

See Also:

Bean Binding Tag Descriptions and Logic and Flow Control Tag Descriptions subsections in the JSP Markup Language (JML) Tag Descriptions section of Chapter 3 of Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on these JML tags.

Alternatively, you could write Java code to implement the tag.

WebLogic Server repeat Tag

The OC4J equivalent for this tag is the jml:foreach tag. This tag provides the ability to iterate over a homogeneous set of values. The body of the tag is executed once per element in the set. This tag currently supports iterations over the following types of data structures:

However, these tags do not cover data structures such as Iterators, Collections, and the keys of a hashtable.

See Also:

The Logic and Flow Control Tag Descriptions subsection in the JSP Markup Language (JML) Tag Descriptions section of Chapter 3 of Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on this JML tag.

For ResultSets and ResultSetMetaData, OC4J provides tags called the SQL Tags for Data Access. These tags provide functionality very similar to that provided by the WebLogic Server repeat tag. The dbNextRow tag is the tag that you are likely to be most interested in. This tag can be used to process each row of a result set obtained in a dbQuery tag and associated with the specified queryId. Place the processing code in the tag body, between the dbNextRow start and end tags. The code in the body is executed for each row of the result set.

See Also:

  • The Custom Data-Access Tag Library subsection in the SQL Tags for Data Access section of Chapter 4 of Oracle Application Server Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on these JML tags.

  • Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide for detailed information about the standard JSP tag library framework and tag-extra-info classes.

Precompiling JSP Pages

JSP pages are compiled automatically by the JSP compiler. However, when testing and debugging JSP pages, you may want to access the JSP compiler directly.

The JSP compiler parses a .jsp file into a .java file. The standard Java compiler is then used to compile the .java file into a .class file.

Using the WebLogic Server JSP Compiler

To start the WebLogic Server JSP compiler, type the following command in your WebLogic Server command line environment:

java weblogic.jspc -options fileName

The fileName parameter refers to the name of the JSP page to be compiled. Options may be specified before or after the JSP page name. The following example demonstrates the use of the -d option to compile myFile.jsp into the destination directory weblogic/classes:

java weblogic.jspc -d /weblogic/classes myFile.jsp

Using the OC4J JSP Pre-translator

In addition to the standard jsp_precompile mechanism, OC4J provides a command-line utility called ojspc for pre-translating JSP pages.

Consider the example where the JSP page, HelloWorld.jsp, is located in the following OC4J default web application directory (copy the HelloWorld.jsp file from <ORACLE_HOME>/j2ee/home/default-web-app/, or the Windows equivalent, to this subdirectory):

UNIX:
<ORACLE_HOME>/j2ee/home/default-web-app/examples/jsp/

Windows:
<ORACLE_HOME>\j2ee\home\default-web-app\examples\jsp\

To pre-translate this JSP page, set your current directory to the application root directory, then, in ojspc, set the _pages directory as the output base directory using the -d option. This results in the appropriate package name and file hierarchy. To illustrate:


Note:

Ensure that the <ORACLE_HOME>/jdk/bin is set in the path environment variable so that the correct java executable is used for ojspc.


In UNIX (assume % is a UNIX prompt):

% cd j2ee/home/default-web-app
% ojspc -d ../application-deployments/default/defaultWebApp/persistence/_pages 
     examples/jsp/HelloWorld.jsp

In Windows (in a command prompt window and where Oracle is the Oracle Home for your Oracle Application Server installation):

C:\>cd Oracle\j2ee\home\default-web-app
C:\>ojspc -d ../application-deployments/default/defaultWebApp/persistence/_pages 
     examples/jsp/HelloWorld.jsp

The directory structure above specifies an application-relative path of examples/jsp/HelloWorld.jsp. The translated JSP can be found in
<ORACLE_HOME>/j2ee/home/application-deployments/default/
defaultWebApp/persistence/_pages/_examples/_jsp/
for UNIX

or

<ORACLE_HOME>\j2ee\home\application-deployments\default\
defaultWebApp\persistence\_pages\_examples\_jsp\
for Windows.

At execution time, the JSP container looks for compiled JSP files in the _pages subdirectory. The _examples/_jsp/ subdirectory would be created automatically by ojspc if run as in the above example.

Invoke the JSP page through the URL http://<hostname>:7777/j2ee/examples/jsp/HelloWorld.jsp. Notice that response time is faster than without pre-translating.

See Also:

The chapter JSP Translation and Deployment in Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide.

Standard JSP Pre-translation Without Execution (based on the JSP 1.1 specification)

You can specify JSP pre-translation, without execution, by enabling the standard jsp_precompile request parameter when invoking a JSP page from the browser. For instance, http://<hostname>:<port>/foo.jsp?jsp_precompile=true

Using the <ORACLE_HOME>/j2ee/home/default-web-app/HelloWorld.jsp file (or Windows equivalent) as an example, erase all the "_HelloWorld*" files in:

UNIX:
<ORACLE_HOME>/j2ee/home/application-deployments/default/
defaultWebApp/persistence/_pages/

Windows:
<ORACLE_HOME>\j2ee\home\application-deployments\default\
defaultWebApp\persistence\_pages\

Then, invoke the URL http://<hostname>:7777/j2ee/HelloWorld.jsp?jsp_precompile=true. The pre-translation is performed but the page does not appear on your browser. Check the _pages subdirectory for the translated files.

Configure the JSP Container for Execution with Binary Files Only

You can avoid exposing your JSP page source, for proprietary or security reasons, by pre-translating the pages and deploying only the translated and compiled binary files. JSP pages that are pre-translated, either from previous execution in an on-demand translation scenario or by using ojspc, can be deployed to any standard J2EE environment.

For further details, refer to the Oracle Application Server Containers for J2EE Support for JavaServer Pages Developer's Guide.


Go to previous page Go to next page
Oracle
Copyright © 2003 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Table Of Contents
Contents
Go To Index
Index