The Java Servlet interface conforms to version 2.3 of the Servlet Specification and will run under any web server that supports that Servlet interface.
The Java Servlet web server interface is located in the runtime/servlet subdirectory. Under Unix, Tomcat generally installs in a directory named jakarta-tomcat-X.X. Under Windows, the directory is called 'Apache Tomcat X.X. The examples below use the Windows naming. If you are running under Unix, make the appropriate substitutions.
In order to run this servlet under Tomcat (where X.X is replaced by the version of Tomcat you are running, and N.N by the version of Java you are running):
In your main knowledgebase object, you must have these minimal HTML elements which are inserted above and below all questions asked of the user:
| Property Name | Minimal Value |
question_top |
<HTML> |
question_bottom |
<INPUT NAME="Submit" TYPE="Submit" VALUE="Continue"> </INPUT> </FORM> </BODY> </HTML> |
output_continue |
<FORM METHOD="GET" ACTION= |
The %system(form_url)% will be replaced at runtime with the rewritten URL for the servlet. This URL is generated by most servlet containers to preserve the session id when cookies are not available or are not used. You can hard-code your program name instead if you do not need this feature (e.g. /amzi/KW). The program name used in question_bottom and output_continue must be the same and must match the servlet URL.
In addition, some jigs (notably Basic) also have an output_continue property in the knowledgebase object. This is used when there is output for the user and the reasoning process is not complete. That is, some intermediate results or information are being displayed for the user. In this case the output_continue contents are added to the web page and are an empty HTML form that continues the reasoning process.
In addition the following properties are passed to your web server:
Parameter |
Description |
Examples |
charset |
The character set used in your knowledgebase |
ISO-8859-1 big5 |
To run your knowledgebase, type into your browser one of the following URLs:
Unix: http://127.0.0.1:8080/amzi/KW?kb_file=hello.kb
Windows: http://localhost:8080/amzi/KW?kb_file=hello.kb
Replace the 127.0.0.1 or 'localhost' with the name (www.company.com) or IP address of the server you have installed the KnowledgeWright servlet on.
Some applications may want to start the reasoning process by having the user answer a fixed set of questions at the outset. To do this you create an HTML file with an HTML form in it. The form elements must have names and values that match question objects in your knowledgebase. The 'submit' button is set to invoke KW (e.g. /amzi/KW). You must specify a kb_file by creating a hidden input named kb_file with a value that is the name of your knowledgebase. You can also have hidden inputs for directory, temp_directory and log_file (see below).
There are additional parameters that you can specify in the query string. Separate each of the parameters by ampersands (&) and encode them with standard URL encoding. The full set of parameters are:
Parameter |
Description |
Examples |
kb_file |
The name of the knowledgebase file (no quotes) |
amzi_website_advisor.kb |
directory |
The directory where the kb_file is located. |
c:\Tomcat\webapps\amzi /usr/local/tomcat/webapps/amzi |
temp_directory |
The directory where the temporary session files are created as well as log files (if you have specified one) and any other temporary files needed by KnowledgeWright. Note Java Servlets must have write access to this directory. |
c:\Tomcat\temp /usr/local/tomcat/temp |
log_file |
The name of the log file that details the execution. It will have the same contents as the log in the KnowledgeWright Workshop. |
kwrun.log |
html_file |
If you would like to start your knowledgebase with an HTML form for the user to input some answers to questions in your knowledgebase, then use this option to specify the HTML file containing the form. Make sure you have a hidden facts for any of the above parameters. (See above.) |
myform.html |
The first thing to do when you encounter a problem is to specify a log_file in the query string where you invoke the servlet.
To specify your kb file and a log file:
Unix: http://127.0.0.1:8080/amzi/KW?kb_file=hello.kb&log_file=kwrun.log
Windows: http://localhost:8080/amzi/KW?kb_file=hello.kb&log_file=kwrun.log
This will create a log file in the same directory as your knowledgebase file. Study its contents, especially at the bottom to see if the problem is explained.
If that does not make the problem clear, the next step is to specify a log file in Amzi! Prolog + Logic Server. To do this, add the following lines to your amzi.cfg file in the WEB-INF/classes directory:
apitrace = on
logfile = c:\amziapi.log
If you need technical support, please e-mail the browser output when you run KW, your KnowledgeWright log file and Amzi! Logic Server trace file along with your knowledgebase to tech support.
To modify and rebuild the servlet you can use the JBuilder project, servlet_run.jpx. Alternatively:
See the Java Tutorial to learn How to Write Servlets.
To learn about configuring servlets under Tomcat, see the Java Tutorial Lesson on Running Servlets.
For information on how to install and run Tomcat under IIS and Windows see How To Setup TOMCAT 4.0.1 on Windows 2000 with IIS and NT Service