Skip Headers

Oracle9i Application Server Migrating From WebLogic
Release 2 (9.0.2)

Part Number A95109-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 6.0 to Oracle9iAS 9.0.2. 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 6.0 to Oracle9iAS 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, or as a enterprise application archive (EAR) file. The migration of web applications in exploded directory format and EAR file format is addressed in Chapter 3, "Migrating Java Servlets".

Differences Between WebLogic Server and Oracle9iAS JSP Implementations

Since both WebLogic Server and Oracle9iAS Containers for J2EE (OC4J) have implemented the same versions of the Java ServerPages specifications, there are no differences between the two in the core areas. There are a few differences in the JSP 1.2 features each server supports. Each vendor also provides their own JSP custom tags. WebLogic Server provides three specialized JSP tags - cache, repeat, and process - 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 Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference.

OC4J JSP Features

Oracle9iAS 9.0.2 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. For those of you who are familiar with Oracle9iAS 1.0.2.2, the first release of Oracle9iAS 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 Oracle9iAS 9.0.2, 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.

Oracle JDeveloper and OC4J JSP Container

Oracle JDeveloper is integrated with the OC4J JSP container to support the full JSP application development cycle - editing, 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

Simple JSP pages are easily configured and deployed in OC4J. The process used to deploy a JSP page is similar in both WebLogic Server and OC4J.

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:

OEM should be used to deploy any type of applications including JSPs. But for the purpose of this discussion here, we are copying JSP files manually without using OEM.


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 6.0. We chose examples that did not use proprietary extensions.

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

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

1

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

Go to http://localhost:1810 and select the OC4J instance you want to start. Or, use the following dcmctl command:

dcmctl start -i 9ias_instance_name -ct oc4j
-co oc4j_instance_name

where 9ias_instance_name is the name of your Oracle9iAS instance and oc4j_instance_name is the name of the OC4J instance you want to start.

2

Copy the JSP page to the appropriate directory

Copy HelloWorld.jsp from wlserver6.0/samples/examples/jsp/ of your WebLogic Server installation to j2ee/home/default-web-app/ of your OC4J installation

3

Copy any files required by the JSP page

Copy BEA_Button_Final_web.gif from

wlserver6.0/config/examples/applications/examplesWebApp/images/

of your WebLogic Server installation to

j2ee/home/default-web-app/images/

of your OC4J installation. Note that you may have to create the images directory

4

Request the JSP page from your web browser

From your web browser, request the JSP page through the URL

http://localhost:7777/j2ee/HelloWorld.jsp

See Also:

Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference and Oracle9iAS 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 6.0. We chose examples that did not use proprietary extensions.

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

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

1

Copy the tag library file to the appropriate directory

Copy counter.tld from

wlserver6.0/samples/examples/jsp/ tagext/counter/

of the WebLogic Server installation to

j2ee/home/default-web-app/WEB-INF/

of your OC4J installation

2

Copy the JSP page to the appropriate directory

Copy pagehits.jsp from

wlserver6.0/samples/examples/jsp/tagext/counter/

of the WebLogic Server installation to

j2ee/home/default-web-app/

of your OC4J installation

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

wlserver6.0/config/examples/ applications/examplesWebApp/WEB-INF/ classes/examples/jsp/tagext/counter/

of the WebLogic Server installation to

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.

4

Copy image files used by the JSP file

Copy the directory containing the image files from

wlserver6.0/samples/examples/jsp/tagext/counter/images/numbers/

of the WebLogic Server installation to

j2ee/home/default-web-app/images/numbers/

of your OC4J installation.

Note that you may have to create the images/numbers directory

5

Modify the appropriate web application deployment descriptor and save the changes

Add the following to the web.xml file located in the

j2ee/home/default-web-app/WEB-INF/

directory of your OC4J installation (<taglib> is a child element of <web-app>):

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

6

Start the OC4J instance, if it is not currently running.

Go to http://localhost:1810 and select the OC4J instance you want to start. Or, use the following dcmctl command:

dcmctl start -i 9ias_instance_name -ct
oc4j -co oc4j_instance_name

where 9ias_instance_name is the name of your Oracle9iAS instance and oc4j_instance_name is the name of the OC4J instance you want to start.

7

Request the JSP file from your web browser

From your web browser, use the URL

http://localhost:7777/j2ee/pagehits.jsp

See Also:

  • Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference for detailed information on configuring and deploying JSP pages.

  • Oracle9iAS 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 option is to use the WebLogic tag library by deploying it on OC4J. This option is discussed in the previous section, "Migrating a Custom JSP Tag Library". You can then migrate to the Oracle JSP tags if required. In the future, tools or automated scripts may be available to make the code conversion easier.

If WebLogic custom tags are used sparingly throughout your web application, then the best option is to modify the JSP pages to use the Oracle 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:

Chapter 6 and Chapter 7 of Oracle9iAS 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 Oracle9iAS 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 Oracle9iAS 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 Oracle9iAS Containers for J2EE JSP Tag Libraries and Utilities Reference for detailed information on these JML tags.

  • Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference 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:

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 pretranslating JSP pages.

Consider the example where the JSP page, HelloWorld.jsp, is located in the OC4J default web application directory j2ee/home/default-web-app/examples/jsp/. (Copy the HelloWorld.jsp file from j2ee/home/default-web-app/ to this subdirectory.)

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 (assume % is a UNIX prompt):

% cd j2ee/home/default-web-app
% ojspc -d ../application-deployments/default/defaultWebApp/temp/_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 j2ee/home/application-deployments/default/defaultWebApp/temp/_pages/_examples/_jsp/.

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://localhost:7777/j2ee/examples/jsp/HelloWorld.jsp. Notice that response time is faster than without pre-translating.

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 j2ee/home/default-web-app/HelloWorld.jsp file as an example, erase all the "_HelloWorld*" files in j2ee/home/application-deployments/default/defaultWebApp/temp/_pages/. Then, invoke the URL http://localhost: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 Oracle9iAS Containers for J2EE Support for JavaServer Pages Reference.


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

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