Resources

SAS® AppDev Studio 3.0 Developer's Site

Deploying with JSASNetCopy

Introduction

So you're using JSASNetCopy and have tested your applet in AppDev Studio. Now you want to make your applet available to others. This document describes what you (and possibly your administrator) need to do in order to deploy your applet.

Overview

There are three types of resources a browser needs in order to view an applet using JSASNetCopy:

  1. HTML resources for the page declaring the applet
  2. Class files and resources for the applet
  3. JSASNetCopy resources

While downloaded class libraries might properly be considered applet resources, they are shared among many applets and this paper treats them as JSASNetCopy resources. All of these resources must be available on a server for the browser to download.

HTML resources

Obviously, the html file and any images, style sheets or other resources it uses must be copied to the server.

Applet resources

Class files, images, properties files and other data files for the applet must be available on the server. When copying, preserve the locations of files relative to each other. A simple applet might have all content in a single directory, but an applet created with a package will have class files in a sub-directory corresponding to the package. For example, an applet with package my.applet.pkg would have class files which should be copied to server sub-directory <codebase>/my/applet/pkg/.

Rather than copying applet resource files individually into various sub-directories, the resources can be combined into one or more jar files. Jars are .zip files with some associated conventions (such as the .jar extension) and can be viewed with standard .zip file tools. Using jars can improve applet startup time by reducing the number of round-trip file requests a browser must make. Also, jars are often compressed, further reducing download time.

One easy way to create a jar for your applet is to use the WebAF Package Wizard (Tools menu --> wizards --> Package Wizard). In addition to creating a .jar file, the WebAF Package Wizard will also create a sample copy of your HTML file with the necessary changes to reference the created .jar file. Copy the .jar and the HTML file to your Web server and edit the HTML file as desired.

Whether the applet resources are loose files or stored in jars, the Web server location to which they should be copied is called the applet codebase. By default, an applet's codebase is the same directory the HTML file is in. The applet tag in the HTML may optionally specify a codebase URL (relative or absolute) which points to a different location (or even a different Web server).

When using JSASNetCopy, the HTML initially runs the JSASNetCopy applet, so the codebase is used to point to the location of JSASNetCopy resources. The actual codebase JSASNetCopy will use when running your applet still defaults to the directory the HTML file is in, or is specified in a <param> tag in the HTML with the name Applet:CODEBASE. When using WebAF, these details are managed for you -- just specify any parameters needed for your applet in the project properties, and WebAF will make the HTML changes needed to use JSASNetCopy.

JSASNetCopy resources

JSASNetCopy resources consist of the JSASNetCopy code (contained in jars), a configuration file and a set of class libraries (jars) which JSASNetCopy might need to download to client machines. This set of resources is generally stored on the Web server in its own location and then referenced by multiple applets.

Historically, the codebase for JSASNetCopy itself has been /sasweb/Tools/JSASNetCopy and this is still the default. If your Web server serves applets created with AppDev Studio versions prior to 3.0, it is recommended that the new set of JSASNetCopy resources be made available at this location. If supporting earlier applets is not an issue, or if you're willing to update all applets using JSASNetCopy on the Web server, then any location may be used for the JSASNetCopy resources, so long as the same JSASNetCopy base location is specified in the WebAF project properties.

JSASNetCopy Web app

The set of JSASNetCopy resources is available as a Web app .war file. If your server runs a Web app container, you can make the entire set of JSASNetCopy resources available on your server by deploying JSASNetCopy.war found in <ADS install location>/Java/JSASNetCopy/ to your container with a context name of sasweb/Tools/JSASNetCopy.

Simple Web server

There is currently no dynamic content in the set of JSASNetCopy resources. Deploying the JSASNetCopy resources as a Web app is merely a convenience. If your Web server does not run a Web app container, or if you prefer to not use a Web app, copy the contents of the JSASNetCopy Web app (optionally without the WEB-INF and META-INF sub-directories) to a location on your Web server which will be served as /sasweb/Tools/JSASNetCopy/. The Web app contents can be extracted from the JSASNetCopy.war file with normal zip tools. The same content in JSASNetCopy.war is also available under <ADS install location>/Java/JSASNetCopy/webapp/.

A Simple Example

Deploy the JSASNetCopy resources

Copy the files in <ADS install location>/Java/JSASNetCopy/webapp/ to <web server document root>/sasweb/Tools/JSASNetCopy/ on the Web server.

Create an applet

In WebAF, make sure that the JSASNetCopy URL in the project properties (File menu --> Project Properties --> HTML) matches your Web server. Create, build and test an applet project. When ready, package the applet files into a jar using the WebAF Package Wizard.

Deploy the applet

Copy the files generated by the Package Wizard (<project name>.jar and <project name>.html) to a directory on the Web server, say, <web server document root>/applets/.

View the applet at http://<web server>/applets/<project name>.html.