Using programs with your server

n addition to serving HTML documents, your server can run programs that interact with clients in many ways. These applications that run on the server computer are called server-side applications. (As opposed to client-side applications, which are transmitted to the client, where they run on the client machine.)

Your server can run these types of server-side applications:

Installing server-side programs

Java applets, LiveWire applications, and CGI programs have different strengths and uses: Java is a full-featured programing language created for creating network applications. LiveWire programs are written in JavaScript, a scripting language based on Java; it is easier to learn than an entire programing language, and is useful for creating programs quickly. CGI (Common Gateway Interface) programs can be written in C, Perl, or other programming languages; what makes them all CGI programs is the standard way they accept and return information.

Each type of program is installed onto the server differently. The following list summarizes the procedures:

Installing server-side Java applets

Java is a programming language based on C++ designed for platform-independent application development. Server-side Java applets can be very powerful, allowing people a greater range of options than CGI programs (see page 119). Java applets also offer greater portability than CGI programs, because of their platform-independent nature. For example, if you have a server-side Java applet that works on a Unix server, you can also use it with a server running on Windows NT. (Assuming both servers are Java-enabled.) Also like a CGI program, a Java applet is triggered by a client sending or requesting information from a URL.

To use server-side Java applets with your server, you must enable your server's Java interpreter, and copy all Java applets into a specified directory, as described below. All server-side Java applets must be named in the format name.class. (For more information on creating Java applets that work with your server refer to the Programmer's Guide.)

To enable your server to use server-side Java applets,

  1. In the server manager, click Programs|Java. The Java form appears.
  2. Click the Yes button to enable the Java interpreter.
  3. Specify a Java applet directory by typing it in the field labeled Java applet directory. It must be a directory somewhere under your server root. It doesn't have to be under your document directory, however.
  4. Click the OK button.
  5. Save and apply your changes. Be sure to copy all server-side Java applets into the directory you've specified.

Installing LiveWire applications

LiveWire applications are written in JavaScript, a scripting language for dynamic client/server interaction. You install and configure LiveWire applications with the LiveWire Application Manager, a separate application that you can access through the Server Manager.

For detailed information on using the LiveWire Application Manager, refer to the LiveWire Developer's Guide. Also, be certain to read the following section, "Securing the LiveWire Application Manager."

After you create a LiveWire application, install it onto the server through these steps.

  1. In the server manager, click Programs|LiveWire.
  2. Click the Application Manager link. The LiveWire Application Manager appears in a new Navigator window.
  3. In the left frame of the Application Manager, click the Add button. The Add Application form appears in the right frame.
  4. Type the name of the LiveWire application in the Name field.
  5. In the Web File Path field, type the absolute path to the .web file for the application.
  6. In the Default field, note what file to send to a client who does not indicate a specific page for the application. This page is sent if the client has visited this application before. This is an optional parameter.
  7. In the Initial field, note what file to send to a client who does not indicate a specific page for the application. This page is sent if the client has not visited this application before. This is an optional parameter.
  8. In the External Libraries field, specify the absolute paths of any libraries to be used with the application
  9. In the Client Object Maintenance field, specify the mode for maintaining the client object.
  10. Click the Enter button.
    Note
    Don't give any LiveWire applications the same names as any sub-directories of your primary document directory. If you do this, the server will no longer correctly process requests from the directory. For example, if you have a directory http://yourserver.domain.com/bug, and a LiveWire application named bug, all requests for any files in the bug directory (or any of its subdirectories) will attempt to launch the bug LiveWire application.

Securing the LiveWire Application Manager

Warning!
Your LiveWire Application Manager runs on your regular server (rather than on the administration server, which runs the server manager). The LiveWire Application Manager is installed into the livewire/appmgr directory off of your server's root directory, and can be accessed without the server manager with this URL: http://yourserver.domain.com/appmgr.

Consequently, you should use configuration styles to restrict access to the Application Manager URL and the applications' URIs so that only you and any other trusted administrators can access them.

To set access control for multiple directories, create a configuration style that contains all of the directories. Then apply access control to that configuration style. For more about configuration styles, refer to "Working with configuration styles" on page 52. For more information on restricting access to part of your server, see "Controlling access to your server" on page 69.

Installing CGI programs

Common Gateway Interface, or CGI, programs can be created with any number of programming languages. On a Unix machine, you're likely to find CGI programs written as Bourne shell or Perl scripts. On a Windows computer, you might find CGI programs written in C++, or Visual Basic.

Regardless of the programming language, all CGI programs accept and return data in the same manner, as described in the Programmer's Guide.

There are two ways to store CGI programs on your server machine:

Specifying a CGI directory

To specify a CGI-only directory,

  1. Click Programs|CGI Directory. The CGI Directory form appears.
  2. In the URL Prefix text field, type the URL prefix you want this directory to appear as. That is, the text you type appears as the directory for the CGI programs in URLs. For example, if you type cgi-programs as the URL prefix, then all URLs to these CGI programs have the structure http://yourserver.domain.com/cgi-programs/program-name. Note: the URL prefix you specify can be different than the real CGI directory you specify in the next step.

  3. In the CGI Directory text field, type the location of the directory as a relative path from your server root. Note that this directory doesn't have to be under your document root. This is why you need to specify a URL prefix in the previous step.
  4. Click OK.
  5. Save and apply your changes. To remove an existing CGI directory, click that directory's Remove button in the CGI Directory Form. To change the URL prefix or CGI directory of an existing directory, click that directory's Edit button.

    Copy your CGI programs into the directories you've specified. Remember--any file in those directories will be processed as a CGI file.

Specifying CGI as a file type

To specify CGI programs as a file type,

  1. Click Programs|CGI File Type. The CGI as a File Type form appears.
  2. Choose the resource you want this to change to apply to. Note that this resource must be your entire server or a directory--it can't be a file or wildcard pattern.
  3. Click the Yes radio button.
  4. Click OK.
  5. Save and apply your changes. The CGI files can reside in or beneath the directory you have specified, and they must have the extensions .BAT, .EXE, or .CGI. Any non-CGI files with those extensions will be processed by your server as CGI files, causing errors.

    Netscape servers support version 1.1 of the Windows CGI specification.

Specifying Windows CGI as a file type

Installing client-side programs

Installing client-side programs into your server is a relatively easy. There are two types of client-side programs: Java applets, and JavaScript programs. Client-side Java applets are executable files that can reside anywhere under your server's primary document root. Client-side JavaScript programs are imbedded in HTML files.

Installing client-side Java

Creating client-side Java applets is outside of the scope of this book, but once you've created an applet, you copy it into a directory your server can serve from. To send it to a client it must be referenced in an HTML file. For more information on referencing client-side Java applets in HTML, refer to the Netscape HTML Reference, included with this server.

Installing client-side JavaScript

Client-side JavaScript programs are created by lines of JavaScript code embedded in HTML files. The HTML travels from the server to the client, and once there, Navigator interprets the JavaScript code and performs the specified actions.

JavaScript can work in conjunction with server-side Java or LiveWire programs if both sides are set up to pass parameters back and forth. For more information on embedding JavaScript in HTML and using client-side JavaScript with other programs, refer to the JavaScript Guide.