Using programs with your server

In 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. (Client-side applications, which are transmitted to the client, run on the client machine.)

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

All but the plug-ins run in conjunction with your server, providing extra programs for clients to take advantage of, like games, search tools, group scheduling programs, and so forth. Plug-ins replace your server's features with new ones, like a different way to control access, or different logging mechanisms. This chapter describes how to install Java applets, LiveWire applications, and CGI programs onto your server. To learn about Netscape Server Plug-in API programs, refer to the Programmer's Guide, which is available online.

Additionally, your server can send these types of client-side applications to clients:

This chapter deals mainly with the installation and configuration of server-side programs, although you'll find instructions on sending client-side applications to clients on page 125. For more detailed programming information, see the online Programmer's Guide.

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:

These installation procedures are described in the following sections.

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 powerful, allowing people a greater range of options than CGI programs (see page 123). 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 or Windows 95, 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 here. 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 online Programmer's Guide.)

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

  1. In the Server Manager, choose 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 Java applet directory field. 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 or its online help. Also, be certain to read the following section, "Securing the LiveWire Application Manager."

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

  1. In the Server Manager, choose 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 subdirectories of your primary document directory. If you do, 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 LiveWire application bug.

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 54. For more information on restricting access to part of your server, see "Controlling access to your server" on page 71.

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 online Programmer's Guide.

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

After you configure your server with either of these options, you move all of your CGI programs in the appropriate directory, or give them the appropriate extensions. You can also use both options simultaneously--you can have CGI-only directories and a CGI-specific file-type extension.

There are benefits to either implementation. If you want to keep a close eye on all CGI programs that you or anyone else might add, keep them in specified directories. If you don't need to keep watch that closely on your CGI programs, you could keep them in the same directories as your HTML files, and choose the file type alternative.

Note If you choose the directory option, your server will attempt to interpret any file you place in that directory as a CGI program. By the same token, if you choose the file type option, your server will attempt to process any files with the file extensions .CGI, .EXE, or .BAT as CGI programs. Depending on the text within the files, this will usually cause some kind of error.

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 the reason that 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.
  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 file extensions .BAT, .EXE, or .CGI. Any non-CGI files with those extensions will be processed by your server as CGI files, causing errors.

    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 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.

    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 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 online JavaScript Guide.