Sun Java System Web Server 7.0 Developer's Guide


Netscape Server Application Programming Interface (NSAPI) is a set of C functions for implementing extensions to the server. These extensions are known as server plug-ins.

Using NSAPI, you can write plug-ins to extend the functionality of Web Server. An NSAPI plug-in defines one or more Server Application Functions (SAFs). You can develop SAFs for implementing custom authorization, custom logging, and for other ways of modifying how Sun Java System Web Server handles requests. For more information, see the Sun Java System Web Server 7.0 NSAPI Developer’s Guide.

The file obj.conf contains instructions (known as directives) that tell the server how to process requests received from clients. Each instruction is enacted either during server initialization or during a particular stage of the request-handling process. Each instruction invokes a SAF.

For example, the following instruction is invoked when the request method is GET and the requested resource is of type text/html. This instruction calls the append-trailer function with a trailer argument of <H4><font color=green>Served by 7.0</font></H4>. The append-trailer function simply returns the requested resource to the client, in this case an HTML file, and appends the given trailer to it.

Service method=GET type="text/html" fn=append-trailer trailer=
                             "<H4><font color=green>Served by 7.0</font></H4>"

Web Server has a set of predefined SAFs. It also has a library of NSAPI functions for developing your own SAFs to modify the way the server handles requests. For more information about predefined SAFs, see the Sun Java System Web Server 7.0 Administrator’s Configuration File Reference . For more information about custom SAFs, see the Sun Java System Web Server 7.0 NSAPI Developer’s Guide.

Note –

The file obj.conf is essential for the operation of the server. If it does not exist, the server cannot work, because it has nowhere to look for instructions on how to handle requests.

Note –

When defining new SAFs, include the header function nsapi.h (which is in install_dir/include) to have access to all NSAPI functions.

Installing NSAPI Plug-ins

To load new NSAPI plug-ins containing customized SAFs into the server, add an Init directive to magnus.conf to load the shared library file that defines the new SAFs. This directive must call the load-modules function, which takes the following arguments: