IBM Research
 

Web Server Plugin

Try It Out

  1. Set up the Plugin
    • Register the Web Server plugin. At the WBI console, type (on one line)
         register
            com/ibm/wbi/examples/webserver/webserver.reg
      Alternatively you can register it using the Graphical User Interface.
    • Check to see whether the new plugin is registered and enabled and that the old one is disabled. Go to the WBI Setup page. The Firewall plugin should be listed in the table with a checkmark next to its name. If the plugin is not listed, try registering it again. If the checkmark is not there, click on the box to the left of the plugin name.
    • Open another browser window. Use that window to try out the plugin, and use this window to display the documentation. (To open another window using Microsoft Internet Explorer, go to File -> New -> Window. To open a window using Netscape Navigator, go to File -> New -> Navigator Window.)

  2. Go to: http://localhost:8088/doc (if your WBI is running on localhost to see the WBI documentation. This plugin is a simple web server that is configurable, and set up by default to serve up the WBI docs.

  3. Having Trouble?


What It Does

The WebServerPlugin provides a simple web server that can be set up from configuration files. It is set up to serve the WBI documentation by default. You can change this by modifying the server configuration file. Note that the server can serve files from the file system and it can process CGIs. In addition, it can be addressed as a proxy (when WBI is set to be your browser's proxy) and it can also be addressed simply as a server (i.e., you can treat it like any web server and obtain files by typing in URLs).

Setting up the server

See the file etc/plugins/ibm/webserver/home.prop for sample set up file. For each server root/file system root pair, simply add another line to the file that contains settings. The configuration file format is as follows:

    ProxyServerName = _wbi
/files = d:\\wbiserver\\files
/doit = d:\\wbiserver\\cgi\\doit.exe, true

Note that the "ProxyServerName" can be left out, and this web server will only respond to direct requests (not proxy requests). Note also that you can specify cgi's by adding a ",true" of the end of the line. Thus, in this case you can get files from the server (if it is running on localhost on port 8088) by asking for:

   http://localhost:8088/files/foo.html

and you can get the "doit" script executed by asking for:

   http://localhost:8088/doit

and with the "doit" case, you can also pass query args in the URL, such as:

   http://localhost:8088/doit?foo=foo&bar=bar+baz
Or if you're set up to use WBI as a proxy, then you can also ask for:

   http://_wbi/files/foo.html
http://_wbi/doit
http://_wbi/doit?foo=foo&bar=bar+baz


How It Works

The WebServerPlugin is rather straightforward. It simply sets up a file generator and a cgi generator based on settings found in the configuration file. More precisely, the plugin's initialize method loops through lines in the cofiguration file, instantiating and setting the rule condition for either a ServerFileGenerator or a CgiGenerator based on the settings contained in the line. The CgiGenerator is a simply a bean in the beans package. The ServerFileGenerator simply wrappers a bean.


Known Problems

  1. It is currently set up to serve the WBI documentation only. If you want to serve other fies or process forms, configure the web server in the etc/plugins/ibm/webserver/home.prop file.


Some key WBI classes that were used:

Package com.ibm.wbi.protocol.http.beans
FileGenerator ServerFileGenerator simply passes off control (via forwardRequest) to a FileGenerator.
CgiGenerator Called to process script or other programs, as specified in the configuration file.
Package com.ibm.wbi.persistent
Section

Used in initialization to determine the web server settings.


The Source

WebServerPlugin.java
Contains the entire plugin source.
webserver.reg
Contains the necessary code to register the plugin with WBI. Registration is done through WBI during runtime.
etc/plugins/ibm/webserver/home.prop
Web server configuration file.