Restaurant Reservation System (RRS) Application
iPlanetTM Application Server Samples

Updated June 12, 2001

The Restaurant Reservation System (RRS) sample application provides a web-based interface to a basic online restaurant reservation service. A collection of servlets and JSP provide customers with restaurant search and reservation services. The restaurant owners are able to check reservations in database and observe customer information.

The RRS application is designed to support multiple languages and demonstrates internationalization features in iPlanet Application Server. iPlanet Application Server provides more than thirty international APIs to aid in the development of global application. By using these APIs, the RRS application determines which localized page should be displayed for each client according to acceptable language of the browser. Currently, it supports only English and Japanese, but it can be extensible for most of the popular locales.

Setting Up the Environment

Getting Started includes a checklist of prerequisites for deploying sample applications to iPlanet.

Configuring the Database describes how to setup the database schema, load the content and register the JDBC data sources for the RRS application.

Deploying and Running the Application

Select one of two approaches to deploying the application:

Command Line-based Deployment describes how to manually register the application in iPlanet using a Command Line Interface (CLI). This is the fastest means of deploying the application.

GUI-based Deployment describes how to use the iPlanet Deployment Tool to import and deploy the application. It also addresses assembling the application from scratch using the Deployment Tool.

Running the Application describes how to start the application, navigate through it and how to troubleshoot in the event of problems.

Further Exploration

Compiling and Assembling the Application describes how to use command line tools to recompile the sources and rebuild the WAR and EAR files.

Setting Bitstream Cyberbit font describes how to download and install Bitstream Cyberbit font to display Japanese pages with Netscape Navigator4.x on Win9x/NT.


Configuring the Database

The RRS sample application requires the following database setup prior to running the application:
Ensure Database Requirements are Met

Ensure Database Driver is Registered

Identify or Create a Database User

Create and Populate Sample Database Tables

Ensure Database Requirements are Met

See the iPlanet Application Server Release Notes for database version requirements. Database population and setup scripts are provided for Oracle server. Other databases supported by iAS should work in conjunction with RRS, but iPlanet has not tested these combinations.

Note: This sample does not support PointBase.

Ensure Database Driver is Registered

This section describes how to register an underlying database driver with the application server in the event that a driver was not registered during installation of the application server. The following instructions address only the registration of the database client driver. The subsequent section of this document will describe how to populate the database tables and register JDBC data sources.

Determine if the iPlanet Type 2 Driver is Registered

On UNIX, if during installation the application server, either "Typical" or "Express" installation options were selected, the native database driver will not be registered in the application server. If you are unsure as whether or not the client driver was registered, use the application server's Administrative Tool to determine status of JDBC drivers.
  1. Start the Admin Tool
  2. <application server install path>/ias/bin/ksvradmin
  3. Connect to your application server instance by selecting File->New->Server. Click on Localhost to specify the default connection settings. Enter the application server's administrator's password and click on OK.
  4. Click on the Database button and expand the server name (default name of iAS1) to see the database driver settings.
  5. If you see a red X on the client driver entry of interest, then you need to run the db_setup.sh script to register the native client driver in the application server. Go to the next section to register the driver.
On Windows, the application server automatically detects whether or not drivers for any of the supported databases are available. If a driver is present, the driver will be automatically registered during installation of the application server.

Register Driver if Necessary

For UNIX, if the driver has not been registered (you see the red X in the Admin Tool), then you must use the db_setup.sh command to register the driver with the application server.

UNIX: Database Driver Registration

  1. Ensure that your user ID is the same as the one used to install the application server.
  2. Execute the database driver registration script:
  3. <application server install path>/ias/bin/db_setup.sh
  4. Follow the instructions to register the native client driver. The default application server installation root directory is /usr/iplanet/ias6.
  5. For this sample, you need not register a Resource Manager. (Resource Manager setup is required only in support of distributed and possibly heterogeneous transactions relying on the application server's built-in transaction manager).
  6. Restart the application server using the iascontrol stop and iascontrol start commands.
  7. After you've registered the driver, you can use the application server's Admin Tool (ksvradmin) to verify that the native driver entry no longer shows a red X and that the client library and other settings are accurate.

Identify or Create an RDBMS User

You should ensure that you have an RDBMS user defined for the sample application. You can use either an existing RDBMS user or define a new RDBMS user for the sample application. This RDBMS user will own the tables created for the sample application. The following example shows how to create a new user called rrs using the Oracle SQL Plus utility. It is strongly recommended that a user such as rrs be used to create the sample database tables. This approach will help to avoid confusion between table names used in other applications.

To define a new Oracle user:

  1. Use SQL Plus to define an Oracle user name (e.g. rrs).

  2. SQL > create user rrs identified by rrs;

    Where the first rrs is the user name and the second rrs is the password.
  3. Grant connect, resource, and dba privileges to the rrs Oracle user.

  4. SQL> grant connect, resource, dba to rrs identified by rrs;

Create and Populate the Sample RDBMS Tables

A shell script named setup_<rdbms type>.sh/.bat configures the database tables, populates the tables with sample data and updates the application server's registry with database information to support the RRS sample application. The setup_<rdbms type>.sh/.bat script performs the following steps:

  1. Dynamically creates an XML file describing the JDBC datasource.
  2. Invokes the application server's iasdeploy regdatasource command to register the data source resource in the application server's registry.
  3. Verifies connectivity to the specified database.
  4. Creates the tables required by the RRS application and populates the tables.
Go to the <application server install path>/ias/ias-samples/l10n/rrs/src/schema/ directory and find the setup_<rdbms type>.sh/.bat file that corresponds to the database of interest. Now follow these instructions:
UNIX: Create and Populate RDBMS

Windows: Create and Populate RDBMS

UNIX: Create and Populate RDBMS

  1. Ensure that the RDBMS enviornment variable is set appropriately. For example, ORACLE_HOME or SYBASE.

  2.  
  3. Edit setup_<rdbms type>.sh. Set the GX_ROOTDIR environment variable to the location of the ias/ directory in your application server installation.
For example,
GX_ROOTDIR=/usr/iplanet/ias6/ias
3. Run setup_<dbname>.sh with the following arguments:
setup_ora.sh <TNS name> <dbusername> <dbpassword>
For example using Oracle:
setup_ora.sh iassample rrs rrs

Where:

<TNS Name> is the Oracle service or TNS name which maps to the appropriate Oracle database instance. In the example above, "iassample" is the Oracle service or TNS name. (This assumes that the Oracle client has been configured to recognize "iassample" as a valid Oracles service/TNS name.)

<dbusername> and <dbpassword> are the Oracle user name and password under which the tables will be created and populated. These are also the values that will be used by the sample application to access the Oracle database.

Since the setup_ora.sh script uses sqlplus, ensure that LD_LIBRARY_PATH includes $ORACLE_HOME/lib.

Windows: Create and Populate RDBMS

1. Ensure that the RDBMS enviornment variable is set appropriately. For example, ORACLE_HOME or SYBASE.

2. Run setup_<rdbms type>.bat with the following arguments:

setup_ora <TNS name> <dbusername> <dbpassword>
For example using Oracle:
setup_ora iassample rrs rrs
Where:

<TNS Name> is the Oracle service or TNS name which maps to the appropriate Oracle database instance. In the example above, "iassample" is the Oracle service or TNS name. (This assumes that the Oracle client has been configured to recognize "iassample" as a valid Oracles service/TNS name.)

<dbusername> and <dbpassword> are the Oracle user name and password under which the tables will be created and populated. These are also the values that will be used by the sample application to access the Oracle database.


Command Line-based Deployment

You have a choice of  deploying and registering the application through either command line utilities or the iPlanet Application Server Deployment Tool GUI. Since a complete EAR file is supplied, the fastest means of setting up the application is to use the command line utilities as described in this section. If you would like to experience either deploying through a GUI tool or assembling an application from scratch, then follow instructions in GUI-based Deployment.

The pre-built rrs.ear file is a Enterprise ARchive file that contains the Web Archive (WAR) file of the RRS application. Within the WAR file resides the XML deployment descriptor files, application class files, JSPs and other content required by the application.

Deploying the pre-built rrs.ear file is simple.

1. Go to the root of the sample directory:

install_dir/ias/ias-samples/l10n/rrs/

2. Execute iasdeploy to deploy application to the local application server instance:

iasdeploy deployapp rrs.ear

Refer to the Getting Started section for more information on using the iasdeploy command.

The deployment process involves the following operations:

If you would like to verify the registration of the application, proceed to Verifying Registration.

Otherwise, you're ready to exercise the application by Running the Application.


GUI-Based Deployment

The Deployment Tool provides an easy-to-use means of assembling J2EE applications and deploying applications to iPlanet Application Server. For most cases, use of Deployment Tool is recommended over the approach of manually creating XML-based deployment descriptors and manually assembling J2EE modules and application JAR files.

Two approaches to using the Deployment Tool are described:

Import Pre-existing EAR File to quickly deploy the application to iPlanet using the Deployment Tool. None of the application assembly steps are covered by this section. On average, this approach will take 5-10 minutes.

or

Assemble the Application to learn how to use Deployment Tool to assemble the application from scratch and to deploy it to the application server. On average, this approach will take from 15-30 minutes.

Import Pre-existing EAR File

Since a pre-built Enterprise ARchive (EAR) file for the RRS application is included with the application server, you can use the Deployment Tool to quickly read in the .ear file and deploy it to the application server.

Open the pre-existing RRS EAR file.

  1. Launch the Deployment Tool.
  2. UNIX:
    Execute <iAS install path>/ias/bin/deploytool
    Windows:
    Start->Programs->iPlanet Application Server 6.0->iAS Deployment Tool
  3. Open the rrs.ear file

Assemble the Application

This approach involves assembling the RRS application from scratch. After compiling the Java sources, you will start Deployment Tool and create the application WAR and EAR files. Then you will deploy the application to the application server.

Compile Application Sources

To compile the application sources, simply execute "build compile" under the application's src/ directory. See the section Compiling and Assembling the Application for more information on recompiling the application using the supplied build facility.

Assemble WAR Module

1. Create assembly location:

Create the new directory <application server install path>\ias\ias-samples\l10n\rrs\assemble\ outside the Deployment Tool. You will assemble the application into archive files and save them to this directory.
2. Launch the Deployment Tool:
Start->Programs->iPlanet Application Server 6.0->iAS Deployment Tool

3. Create rrs.war

4. Add the servlet class, JSP and image files to the .war file

5. Edit Descriptor

Now that you've assembled the WAR module, you are ready to create the Enterprise ARchive (EAR) file.

Assemble EAR

1. Create rrs.ear:

2. Include rrs.war:

3. Delete the default deployment descriptor for JSP component.

4. Choose File > Save.

Verifying the Application

Before deploying applications/modules you should confirm that the RRS J2EE application and components conform to the Java 2 Enterprise Edition Specification.

To verify the application

Deploy the Application

You will now deploy the EAR file to a target iPlanet Application Server. During deployment the .ear file is copied to one or more target iPlanet Application Server(s). After the EAR file is deployed to the server, registration occurs. After deployment completes, you will be able to run the application. No server restart is required.

To deploy the application

1. Select the rrs.ear file and choose File > Deploy.
2. If you are using the Deployment Tool for the first time, click Register and complete steps 4 through 6. Otherwise continue with step 7.
3. Enter Host name (machine name) of an application server instance.
4. Enter a port number that represents the application server administrative server (this port defaults to 10817).
5. Enter the application server administrator's user name and password chosen during installation.
6. Click Okay.
7. Select the application server instance in the Register Servers box and click Deploy.
8. Click the Deploy tab to verify the status of the deployment.
- The application has now been successfully deployed on your target server in the install_dir/ias/Apps/rrs directory.
9. Exit the Deployment Tool File > Exit.

Verifying Registration

As an optional step, you can use the iPlanet Application Server Administration Tool to verify that the application has been registered. If you do not want to verify that the application has been registered, proceed directly to Running the Application.
  1. Start the application server's Admin Tool
  2. UNIX:
    <application server install path>/ias/bin/ksvradmin
    Windows:
    Start->Programs->iPlanet Application Server->iAS Administration Tool
  3. Connect to your application server instance by selecting File->New->Server. Click on Localhost to specify the default connection settings. Enter the application server administrator's password and click on OK.
  4. Select the server name (default name of iAS1) and select the Application button in the top right hand corner of the window to see the applications registered in this instance of the application server.
  5. You should see several folders for the "rrs" J2EE application. The "rrs" folder with the world icon represents the web application module.
To see more details associated with the application, you can browse the iPlanet Application Server Registry using a tool named kregedit:
  1. Execute kregedit to start the application server's Registry Editor GUI.
  2. Navigate to the SOFTWARE/iPlanet/Application Server/6.0/ portion of the tree.
  3. Browse the J2EE-Application/ tree and look for the "rrs" application.
  4. Expand the "rrs" folder and explore this portion of the directory tree.
  5. Now open the J2EE-Module/ tree and look for the "rrs" web application module entry.
  6. Expand each of these folders and explore their contents.
  7. Once you find the GUID associated with servlet in the RRS application, you can navigate through the SOFTWARE/iPlanet/Application Server/ClassDef/ folders to find out more details on the servlet. Expanding the matching GUID folder under the ClassDef folder will show you the detailed settings associated with the servlet.

Running the Application

Set Specific Language Support (UNIX Only)

On UNIX only, prior to running the application, add the following 2 lines to install_dir/ias/bin/kjs script:

NLS_LANG=Japanese_Japan.JA16SJIS
export NLS_LANG

Then restart the application server using iascontrol stop followed by iascontrol start.

Configure International Mode in Application Server

In the application server's Administrative Tool, enable International mode.

Restart the application server using iascontrol stop followed by iascontrol start.

Run the Application

Start the application by going to:

http://<hostname>/NASApp/rrs/ShowIndexServlet

List of Customers in Database

name
password
locale/country
Bob Smith
bob
en_US/U.S.A
Rc¾Y
taro
ja_JP/ú{
Scott Tiger
scott
en_US/U.S.A

List of Restaurants in Database

ID
name
localized name
cuisine
price range
1
Shogun Sushi
«Rõi
Japanese
$20 - $40
2
Washington Diner
Vg_Ci[
American
more than $40
3
Cafe Berkeley
JtF o[N[
California
$10 - $20
4
Rome
[}
Italian
more than $40
5
Bangkok
oRN
Thai
$20 - $40
6
Paris
-
French
$10 - $20
7
Alegrias
-
Spanish
more than $40
8
HongKong Restaurant
-
Seafood
$20 - $40
9
Hanoi
-
Vietnamese
less than $10
10
Best One
-
Others
more than $40
101
Golden Gate
S[fQ[g
California
$10 - $20

Administrator Password

You will be required the password to login as the administrator. The password is "admin".

Troubleshooting

If you encounter problems when running the application, review the General Troubleshooting section to learn how to view logs files.

If you encounter squares in place of text in the browser, then see the Setting Bitstream Cyberbit Font section for details on how to correct this problem.


Compiling and Assembling the Application

To easily recompile, assemble and deploy the application, see the Sample Application Build Facility document for details on using a build facility to quickly perform these tasks.

To rebuild the entire sample from scratch, you can simply execute:

build all

From the directory install_dir/ias/ias-samples/l10n/rrs/src/

On UNIX, you might need to modify your PATH to ensure that install_dir/ias/bin is included to pickup the build script.


Setting Bitstream Cyberbit Font

If you are using Netscape navigator 4.X on WinNT as browser, you may get boxes instead of Japanese string when you try to display Japanese pages (see Fig.1). In this case, you will need to install an Unicode font or a Japanese font to your system. This section describes how to download and install Bitstream Cyberbit font for a Netscape navigator.

japanese_error.gif
Fig.1

1. Download and install Bitstream Cyberbit font.

2. Setup for Netscape navigator.
At Netscape navigator,


Copyright (c) 2001 Sun Microsystems, Inc. Some preexisting portions; Copyright (c) 2001 Netscape Communications Corp. All rights reserved.