Anda di halaman 1dari 4

Custom JAR Files Containing Icons and Images

Each time you use an icon or an image (for a splash screen or background), an
HTTP request is sent to the Web server. To reduce the HTTP roundtrips
between the client and the server, you have the ability to store your icons and
images in a Java archive (JAR) file. Using this technique, only one HTTP
roundtrip is necessary to download the JAR file.

Creating a JAR File

The SunSoft JDK comes with an executable called jar. This utility enables you
to store files inside a Java archive. For more information, see
www.java.sun.com.

For example:
jar -cvf myjar.jar Splash.gif Back.gif icon1.gif

This command store three files (Splash.gif, Back.gif, icon1.gif) in a single JAR
file called myjar.jar.

Using Files Within the JAR File

The default search path for the icons and images is relative to the
DocumentBase. However, when you want to use a JAR file to store those files,
the search path must be relative to the CodeBase directory, the directory which
contains the Java applet.

If you want to use a JAR file to store icons and images, you must specify that
the search path is relative to CodeBase using the imageBase parameter in the
formsweb.cfg file or HTML file.

This parameter accepts two different values:

• DocumentBase The search path is relative to the DocumentBase


directory. It is the default behavior.
• CodeBase The search path is relative to the CodeBase directory, which
gives the ability to use JAR files.

In this example, we use a JAR file containing the icons and we specify that the
search should be relative to CodeBase. If the parameter "imageBase" is not set,
the search is relative to DocumentBase and the icons are not retrieved from the
JAR file.
For example (formsweb.cfg):

archive=f90all.jar, icons.jar

imageBase=codebase

Search Path for Icons and Images

The icons and images search path depends on:

• What you specify in your custom application file (for the icons).
• What you specified in the SplashScreen and Background parameters of
your formsweb.cfg file or HTML file (for the images).
• What you specify in the imageBase parameter in your formsweb.cfg file
or HTML file (for both icons and images).

Forms Services searches for the icons depending on what you specify. This
example assumes :

• host is the host name.


• documentbase is the URL pointing to the HTML file.
• codebase is the URL pointing to the location of the starting class file (as
specified in the formsweb.cfg file or HTML file).
• mydir is the URL pointing to your icons or images directory.

DocumentBase

The default search path is relative to the DocumentBase. In this case, you do
not need to specify the imageBase parameter:

Table 3-3 Search Paths for Icons and Images

Search path used by Forms


Location specified Services
Icons default http://host/documentbase
iconpath=mydir http://host/documentbase/mydir

(specified in your application (relative path)


file)
iconpath=/mydir http://host/mydir
Search path used by Forms
Location specified Services

(specified in your application


file) (absolute path)
Images file.gif http://host/documentbase/file.gif

(specified, for example, in


formsweb.cfg as
splashscreen=file.gif)
mydir/file.gif http://host/documentbase/mydir/file.gif

(relative path)
/mydir/file.gif http://host/mydir/file.gif

(absolute path)

CodeBase

Use the imageBase=CodeBase parameter in the formsweb.cfg file to enable the


search of the icons and images in a JAR file:

Table 3-4 Icons and Images Search Paths Used by Oracle9iAS Forms
Services

Location specified Search path used by Forms Services


Icons default http://host/codebase or root of the JAR file
iconpath=mydir http://host/codebase/mydir or in the mydir
directory in the JAR file
(specified in your
application file) (relative path)
iconpath=/mydir http://host/mydir

(specified in your (absolute path)


application file)
No JAR file is used
Images file.gif http://host/codebase/file.gif or root of the JAR
Location specified Search path used by Forms Services
file
mydir/file.gif http://host/codebase/mydir/file.gif or in the
mydir directory in the JAR file
(specified in your
HTML file) (relative path)
/mydir/file.gif http://host/mydir/file.gif

(specified in your (absolute path)


HTML file)
No JAR file is used.