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:
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.
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 140. Also, this chapter is not a programming tutorial or programmer's reference guide. For pointers to more detailed programming information see the Programmer's Guide.
Additionally, on page 139 the steps for specifying a default query handler CGI program are described. (A query handler processes text sent to it via the ISINDEX tag in an HTML file.)
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 very powerful, allowing people a greater range of options than CGI programs (see page 137). 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,
- In the server manager, click Programs|Java. The Java form appears.
- Click the Yes button to enable the Java interpreter.
- 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.
- Click the OK button.
- 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.
- In the server manager, click Programs|LiveWire.
- Click the Application Manager link. The LiveWire Application Manager appears in a new Navigator window.
- In the left frame of the Application Manager, click the Add button. The Add Application form appears in the right frame.
- Type the name of the LiveWire application in the Name field.
- In the Web File Path field, type the absolute path to the .web file for the application.
- 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.
- 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.
- In the External Libraries field, specify the absolute paths of any libraries to be used with the application
- In the Client Object Maintenance field, specify the mode for maintaining the client object.
- 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 58. For more information on restricting access to part of your server, see "Controlling access to your server" on page 83.
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:
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, you should 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 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,
- Click Programs|CGI Directory. The CGI Directory form appears.
- 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.
- 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.
- Click OK.
- 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,
- Click Programs|CGI File Type. The CGI as a File Type form appears.
- 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.
- Click the Yes radio button.
- Click OK.
- 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.
Using the query handler
You can specify a default query handler CGI program. A query handler processes text sent to it via the ISINDEX tag in an HTML file.
Briefly, ISINDEX is similar to a form text field, in that it creates a text field in the HTML page that can accept typed input. Unlike a form, however, the information in the ISINDEX box is immediately submitted when the user presses return. When you specify your default query handler, you instruct your server what program to direct the input to. For an in-depth discussion of the ISINDEX tag, refer to an HTML reference manual.
To set a query handler, do the following:
- Choose Programs|Query Handler.
- Use the Resource Picker to select the resource you want to set a default query handler for. If you choose a directory, the query handler you specify runs only when the server receives a URL for that directory or any file in that directory.
- In the Default Query Handler field, enter the full path for the CGI program you want to use as the default for the resource you chose.
- Click OK.
- Save and apply your changes.
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.