Skip Headers
Oracle® Database Lite Developer's Guide
10g (10.0.0)
Part No. B13788-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

C Web-to-Go Sample Applications

This appendix contains Web-to-Go sample applications. Topics include:

C.1 Introduction

Web-to-Go contains five sample programs that are installed with the Mobile Development Kit for Web-to-Go or the Mobile Server.

C.1.1 The Mobile Server

You can install the demos during Mobile Server installation or by running the batch file instdemo.bat. This batch file is located in the following directory.

&fmv1018;\Mobile\Server\Samples

The command syntax is as follows.

instdemo.bat [SYSTEM_password] [repository_owner] [repository_password]

For example,

instdemo manager mobileadmin manager

C.1.2 The Mobile Development Kit for Web-to-Go

You can install the demos by running the batch file sdkdemos.bat. This batch file is located in the following directory.

&fmv1020;\Mobile\sdk\wtgsdk\src\sdkdemos.bat

C.1.3 Accessing Sample Programs from the Mobile Development Kit for Web-to-Go

The Mobile Development Kit for Web-to-Go is bundled with sample programs that you can access from the following URL.

http://<mobile_server>:7070/

The browser displays icons for different sample programs. To launch a sample program, click the required icon for the corresponding program.

C.1.4 Accessing Sample Programs from the Mobile Server

As Table C-1 describes, the Mobile Server automatically creates the following sample users when you install Web-to-Go demos.

Table C-1 Sample Users

User Password
john john
jack jack
jane jane

The above listed sample users can access the sample programs by logging on to the Mobile Server and clicking any of the sample application icons in the workspace.

C.2 Sample 1 - Hello World

Sample 1, Hello World is a servlet that returns a simple HTML page to the browser. It demonstrates the basic methods of HttpServlet and demonstrates the difference between the POST and GET methods.

C.2.1 Source Code Location

The source code location varies depending on whether you installed the Mobile Server or the Mobile Development Kit for Web-to-Go. Table C-2 describes these locations.

Table C-2 Source Code Locations

Installation Type Source Code Locations
Mobile Server
&fmv1029;\Mobile\Server\samples\sample3\src
Mobile Development Kit for Web-to-Go
The Java source code can be found in the following location.

&fmv1031;\Mobile\Sdk\wtgsdk\src\sample3\servlets


C.2.2 Application Files

Sample 1 contains the HelloWorld.java file. It is the source code for the HelloWorld servlet.

C.3 Sample 3 - Recording Tracker

Sample 3, the Recording Tracker demonstrates how servlets can be used to maintain a database with recording information. The program allows users to search the database and enter recordings and tracks for a recording. Although the recordings are stored in the RECORDINGS table, users can only see their corresponding data when they access this table.

C.3.1 Using Sample 3

When a user goes offline, Web-to-Go automatically creates snapshots on the local client to hold a copy of the data. You can choose the rows that are replicated to the snapshot by adding a subquery to the snapshot definition. This enables Web-to-Go to synchronize specific rows for the user to the local client. In Sample 3, both John and Jack have access to the same data. Jane can only see her own data and no other user has access to it. For more information on setting up a snapshot subquery, see the Oracle Database Lite Administration and Deployment Guide.

C.3.2 Sample 3 Database Tables

Sample 3 contains the following database tables.

  • RECORDINGS

  • RECORDING TYPES

  • TRACKS

As Figure C-1 displays, the database tables are illustrated in the following entity relationship diagram.

Figure C-1 Entity Relationship Diagram

This illustration depicts the entity relationship diagram.

C.3.3 Sample 3 Servlets

Sample 3 contains six different Java servlets. These servlets demonstrate two ways of generating HTML. The DisplayRecord servlet uses the oracle.html package to generate the entire HTML file. The DisplayMasterDetail, ListSearchResults, and SimpleList servlets generate HTML using the base class oracle.lite.web.html.TemplateParser and a static HTML template. In both cases, data is displayed in HTML using the DBTable class. Data changes are processed by the generic servlet ProcessForm, which is part of the oracle.lite.web.html package. DeleteDetail and DeleteMasterDetail extend the class oracle.lite.web.html.DeleteRecords. These servlets execute a request and then redirect the browser to another URL.

C.3.4 Sample 3 Resource Bundle

The Recording Tracker program also illustrates the use of the ListResourceBundle class to manage resources for locale specific strings. By isolating all text strings in a resource bundle, you can write programs that can easily be translated into other languages, or modified to add support for more languages. See SampleResources.java for more detailed information.

C.3.5 Source Code Location

The source code location varies depending on whether you installed the Mobile Server or the Mobile Development Kit for Web-to-Go. Table C-3 describes these locations.

Table C-3 Source Code Locations

Installation Type Source Code Locations
Mobile Server
&fmv1036;\Mobile\Server\samples\sample1\src
Mobile Development Kit for Web-to-Go
The Java source code can be found in the following location.

&fmv1038;\Mobile\Sdk\wtgsdk\src\sample1\servlets


C.3.6 Application Files

Sample 3 contains the following application files.

File Description
EnterSearchCriteria.html The Static HTML file.
sample3.gif The Sample 3 icon that appears in the Web-to-Go workspace.
sample3.html The start page for the application.
sample3.sql The SQL Script that installs the sample3 database objects.
table.sql The SQL script that creates the sample3 database tables.
insert.sql The SQL script that populates the sample3 database tables with data.
drop.sql The SQL script that drops the sample3 database tables.
SampeProgram3.java The source code that contains static definitions for the Sample 3 application.
SampleResources.java The source code for the String Resources used by the servlets.
DisplayMasterDetail.java The source code for the DisplayMasterDetail servlet.
DisplayRecord.java The source code for the DisplayRecord servlet.
SimpleList.java The source code for the SimpleList servlet.
ListSearchResults.java The source code for the ListSearchResults servlet.
DeleteDetail.java The source code for the DeleteDetail servlet.
DeleteMasterDetail.java The source code for the DeleteMasterDetail servlet.
DisplayMasterDetail.html The HTML template, used by the DisplayMasterDetail Servlet.
ListSearchResults.html The HTML template, used by the ListSearchResults Servlet.
SimpleList.html The HTML template, used by the SimpleList Servlet.

C.4 Sample 4 - Hello Applet

Sample 4, the Hello Applet illustrates how applets and servlets can communicate with each other. A Java applet calls a servlet running on the Mobile Server. The servlet responds by sending a string to the applet, which the applet then displays.

C.4.1 Sample 4 Servlets

Sample 4 contains two servlets. The AppServlet servlet generates HTML that instructs the browser to launch the applet. This HTML includes applet parameters that contain the Mobile Server session information. The HelloServlet is called by the applet as part of the applet/servlet communication.

C.4.2 Source Code Location

The source code location varies depending on whether you installed the Mobile Server or the Mobile Development Kit for Web-to-Go. Table C-4 describes these locations.

Table C-4 Source Code Locations

Installation Type Source Code Locations
Mobile Server
&fmv1044;\Mobile\Server\samples\sample1\src
Mobile Development Kit for Web-to-Go
The Java source code can be found in the following location.

&fmv1046;\Mobile\Sdk\wtgsdk\src\sample1\servlets


C.4.3 Application Files

Sample 4 contains the following application files.

File Description
Sample4.gif The Sample 4 icon that appears in the workspace.
Sample4.html The start page for the application.
HelloApplet.java The Java source code for the applet.
AppServlet.java The Java source code for the AppServlet servlet.
HelloServlet.java The Java source code for the HelloServlet servlet.

C.5 Sample 6 - Image Gallery

Sample 6, the Image Gallery demonstrates how to store binary data in the database without using the LONG datatype. When the sample program uploads images to the Mobile Server, it separates them into 255 byte chunks. As a result, you can store the images in a RAW datatype column.

C.5.1 Source Code Location

The source code location varies depending on whether you installed the Mobile Server or the Mobile Development Kit for Web-to-Go. Table C-5 describes these locations.

Table C-5 Source Code Locations

Installation Type Source Code Locations
Mobile Server
&fmv1051;\Mobile\Server\samples\sample1\src
Mobile Development Kit for Web-to-Go
The Java source code can be found in the following location.

&fmv1053;\Mobile\Sdk\wtgsdk\src\sample1\servlets


C.5.2 Application Files

Sample 6 contains the following application files.

File Description
sample6.gif Icon for the application, used in the Web-to-Go workspace.
loadImage.html HTML form to upload an image.
DeleteImage.java Source code for the DeleteImage servlet.
GetImage.java Source code for the GetImage servlet.
Upload.java Source code for the Upload servlet.
ImageList.java Source code for the ImageList servlet.
ViewImage.java Source code for the ViewImage servlet.
RawImage.java The Source code for the RawImage servlet.
ImageList.html The HTML Template used by the ImageList servlet.
ViewImage.html The HTML Template used by the ViewList servlet.
sample6.sql The SQL script that installs the sample6 database objects.
table.sql The SQL script that creates the sample6 database tables.
drop.sql The SQL script that drops the sample6 database tables.

C.6 Sample 7 - Employee Data Applet

Sample 7, the Employee Data Applet, demonstrates how to use JDBC in an applet. The applet connects to the database using the oracle.lite.web.applet.AppletProxy class. This class automatically returns a database connection to the appropriate database depending on the user's connection mode. In online mode, the oracle.lite.web.applet.AppletProxy class returns a connection to the Oracle database. In offline mode, or when using the Mobile Development Kit for Web-to-Go, the class returns a connection to Oracle Database Lite.

Running Sample 7

To successfully run Sample 7, the client webtogo.ora file must be modified to support Applet JDBC connections. The webtogo.ora file is available at the following location.

<WebtoGo_Home>\bin\webtogo.ora

Uncomment the following line in the webtogo.ora file.

#APPLET_SUPPORT_ENABLE=YES

Ensure that the file olite40.jar is recognized by the chosen browser as being in the CLASSPATH.

Normally, the System CLASSPATH is the appropriate location to add the file. However, on some occasions the browser does not recognize changes to the System CLASSPATH, but does recognize changes to the User CLASSPATH. You must try the System CLASSPATH first. As a back up option, you can try the User CLASSPATH.

C.6.1 Source Code Location

The source code location varies depending on whether you installed the Mobile Server or the Mobile Development Kit for Web-to-Go. Table C-6 describes these locations.

Table C-6 Source Code Locations

Installation Type Source Code Locations
Mobile Server
&fmv1059;\Mobile\Server\samples\sample1\src
Mobile Development Kit for Web-to-Go
The Java source code can be found in the following location.

&fmv1061;\Mobile\Sdk\wtgsdk\src\sample1\servlets


C.6.2 Application Files

Sample 7 contains the following application files.

File Description
sample7.gif The application icon that appears in the workspace.
sample7.ahtml The application start page.
AppApplet.java The Java source code for the applet.
ErrorDialog.java The Java source code for error dialog.
sample7.sql The SQL Script to install the sample7 database objects.
table.sql The SQL script that creates the sample7 database tables.
insert.sql The SQL script that populates the sample7 database tables with data.
drop.sql The SQL script that drops any old tables.