OTN Sample Application demonstrating handling of sessions in SMS

Table Of Contents 

This document is organized into following sub-sections

Overview of the Sample Application

Back To Top

Oracle9iAS Wireless presents a framework to develop mobile applications to be accessed "from anywhere, from any device, using any protocol". To achieve this, the developer may need to async-enable the application. The application can now talk to various protocols such as WAP (Wireless Access Protocol), SMS (Short Messaging Service), Voice and others. For more information on Oracle9iAS Wireless Server, click here.

This sample illustrates how to handle sessions in SMS using Oracle9iAS Wireless. Oracle9iAS Wireless makes it very simple to use sessions in the application. A developer does not have to worry about handling/maintaining a session object in the application. The Server does it automatically. The Flight Information scenario is used to demonstrate the feature. The application first asks the user for the starting point and the destination of his/her journey. On entering this, the sample application returns the name and code of the airlines that provides a flight between the two entered cities. (Here, the session is maintained in the server for the particular user. This makes it possible for the server to respond to the subsequent requests. If a request comes from a different device, then a new session is created internally for that request.) The user now selects the flight code and the application returns the day and timings of the flight operating between these two cities for the coming days of this week.

For running the sample through SMS, an elaborate setup is required (a hardware cable connecting the system to the mobile). So, instead of accessing the sample through SMS, we have invoked this sample application using e-mails which serves as asynchronous triggers. This demonstrates the handling and maintainance of sessions in Oracle9iAS Wireless Server.

Required Software

Back To Top

1) Oracle9iAS Enterprise Edition Release 2 V9.0.2(Can be downloaded from here).

2) Oracle9i or later database (Can be downloaded from here).

Notations used

Back To Top

This section will describe the terms used in the document

Notation Description
<OC4J_HOME> If the sample is being deployed into a standalone OC4J (Oracle9iAS Containers for J2EE), then this value will be the folder where OC4J is installed. For example, D:/oc4j.
If the sample is being deployed in 9iAS, then this value will be the folder where iAS middle-tier has been installed. For example, D:/iAS.
<J2EE_HOME> The folder j2ee/home under <OC4J_HOME>. For example, D:/oc4j/j2ee/home.
<SAMPLE_HOME> Folder where this sample resides. For example, if <X> is the folder where the sample was extracted, then <X>/FlightInformationSample would be the value of this Notation.

 

Installation

Back To Top

Step 1. Unjar the provided FlightInformationSample.jar using the following command

> jar xvf FlightInformationSample.jar

Step 2. This sample application requires that the following tables exist in the database

Table Name : Airlines
Column Name Column Type Description
Name VARCHAR2(30) Name of the Airline
Boarding VARCHAR2(30) Starting City of the journey
Destination VARCHAR2(30) Destination of the journey
FlightCode VARCHAR2(3) Code of the flight operating between the boarding and destination city

Table Name : FlightTime
Column Name Column Type Description
FlightCode VARCHAR2(3) Code of the flight operating between the boarding and destination city
Day NUMBER Day of the week in numbers
Time VARCHAR2(5) Time of the flight

To create the tables, run SQL*Plus, connect to your Oracle database as scott/tiger (or any other user) and execute the Install.sql script as shown below

SQL> @<SAMPLE_HOME>/sql/Install.sql

Step 3. Edit <SAMPLE_HOME>/src/oracle/otnsamples/wireless/ConnectionParams.java file in your favorite editor. Change the Host name, port number, SID, username and password to those where the tables were installed in the above step.

Change the following lines:

public final static String hostName     = "insn104a.idc.oracle.com";
public final static String portNumber   = "1522";
public final static String SID          = "ora9idb";
public final static String userName     = "scott";
public final static String userPassword = "tiger";

Step 4. Copy folder <SAMPLE_HOME>/src/flight to <J2EE_HOME>/default-web-app.
             Now copy folder <SAMPLE_HOME>/src/oracle to <J2EE_HOME>/default-web-app/WEB-INF/classes.

Step 5. Go to <J2EE_HOME>/default-web-app/WEB-INF/classes on command prompt and run the following command

javac -d . oracle/otnsamples/wireless/*.java

Make sure that you have <OC4J_HOME>/jdbc/lib/classes12dms.jar in the classpath before running the above command.

Step 6. Start the OC4J server. Now configure the Email Adapter in Oracle9iAS Wireless. Go through the viewlet located here for doing this.

Step 7. Configure the sample application in Oracle9iAS Wireless. More information on this can be seen in the viewlets present here.

 

Running the Application

Back To Top

For running the sample application, first setup an Email ID over IMAP protocol. This can be done by following the viewlets present in Step 6 in the above section. We will refer to the Email ID (which the wireless server is listening) as <WIRELESS_MAIL>. This is rajgupt@idc.oracle.com in the viewlet.

Step 1. Open your favorite Email Client. Create a new mail and write FlightInfo in the subject line (FlightInfo is the name you provide as short name while deploying the application in Oracle9iAS). Send this mail to <WIRELESS_MAIL>. Do not type anything in the body of the mail.

Step 2. After some time you will get a reply from the wireless server. This mail will ask you to enter the starting point and the destination of your journey. Reply to this mail. Remove everything from the body of the mail and type "Bangalore" "Washington" (within double quotes) and send the mail to <WIRELESS_MAIL>.

Step 3. Again you will get a reply mail from the wireless server. This mail will list out the name and code of the Airlines that provides a flight between the two entered cities. Again, reply to this mail and remove everything from the body of the mail. Now, type the flight code of an Airline (from the list returned) in the body of this mail and send it to <Wireless_Mail>. Again, type the flight code within double quotes.

Step 4. After some time, you will get a mail from the wireless server which will list out the day and time of all the flights operating between these two cities from the selected Airline.

During this whole process, wireless server will maintain the session of the user internally. This is the reason why subsequent pages are called for each request.

 

Description of Sample Files

Back To Top

The directory structure of the FlightInformationSample.jar is as shown below :

Directory Files Description
<SAMPLE_HOME>/docs Readme.html This file.
<SAMPLE_HOME>/sql Install.sql This SQL script creates and populates the tables used by the application.
<SAMPLE_HOME>/src/oracle/otnsamples/wireless ConnectionParams.java This java file contains the database connection parameters.
FlightInformation.java This java file contains the different methods used by the sample application.
<SAMPLE_HOME>/src/flight Flight.jsp This file accepts the starting point and the destination of the journey.
Airlines.jsp This file displays the airlines available to the destination from the starting city. It also accepts the airline code from the input device.
FlightTimings.jsp This file displays the day/time of all the flights operating between the starting city and destination by the selected airline.

 



Please enter your comments about this sample in the OTN Sample Code Discussion Forum.
E-mail this page
Printer View Printer View