Oracle® Database Lite Developer's Guide
10g (10.0.0) Part No. B13788-01 |
|
![]() Previous |
![]() Next |
This appendix contains Web-to-Go sample applications. Topics include:
Web-to-Go contains five sample programs that are installed with the Mobile Development Kit for Web-to-Go or 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
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
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.
As Table C-1 describes, the Mobile Server automatically creates the following sample users when you install Web-to-Go demos.
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.
Sample 1, Hello World is a servlet that returns a simple HTML page to the browser. It demonstrates the basic methods of HttpServle
t and demonstrates the difference between the POST and GET methods.
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.
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.
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.
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.
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.
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.
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.
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.
|
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.
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.
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.
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.
|
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.
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.
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. |
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.
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.
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. |