Extended Predicate Java Servlet
This servlet was developed using Java 1.3 and Tomcat 4.0. There are two source
code files named ExtPred.java (the main servlet) and AmziPreds.java (the extended
predicate). It supports both a GET and POST operation. The GET puts up a simple
form for you to enter the full pathname of HTMLDOC.XPL. The POST calls the Amzi!
Logic Server which in turn calls the extended predicate, user_info, and displays
the result.
Building the Sample
- Set JAVA_HOME=c:\jdkN.N
- Set the CLASSPATH to include .;\amzi\lsapis\java20 and servlet.jar. For
Tomcat, servlet.jar is found in jakarta-tomcat-X.X\common\lib.
- Compile ExtPred.java and AmziPreds.java with javac (or open and build the
JBuilder project extpred.jpx).
- Compile htmldoc.pro with acmp (or the Amzi! IDE) and link it into htmldoc.xpl
with alnk (or the Amzi! IDE).
JRUN
In order to run this servlet under JRUN, you need to modify ExtPred.java in
the method doGet() to read
out.println("<form method=post action=\"/servlet/ExtPred\">");
instead of:
out.println("<form method=post action=\"/amzi/ExtPred\">");
This is because the default URL for servlets under JRUN is /servlet.
Running the Sample
Tomcat
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):
- Create a sudirectory in ...Apache Tomcat X.X\webapps named 'amzi'.
- Copy the amzi\samples\internet\servlets\extpred\WEB-INF subdirectory tree
to ...Apache Tomcat X.X\webapps\amzi.
- Copy ExtPred.class and AmziPreds.class to ...Apache Tomcat X.X\webapps\amzi\WEB-INF\classes
- Copy htmldoc.xpl to ...Apache Tomcat X.X\webapps\amzi
- Copy amzi.dll, amzijni.dll (from amzi\bin) to ...Apache Tomcat X.X\webapps\amzi\WEB-INF\classes.
Alternatively, you can load these libraries (and LSXs) explicitly in Java
with Runtime.getRuntime().load(libraryPath) or loadLibrary(libraryName).
- Copy the amzi/ls subdirectory tree (from amzi\lsapis\java20) to ...Apache
Tomcat X.X\webapps\amzi\WEB-INF\classes
- Stop and restart Tomcat
- In your browser type, http://localhost:8080/amzi/Extpred. Enter '\\...Apache
Tomcat X.X\\webapps\\amzi' when prompted for the directory with htmldoc.xpl
in it.
JRUN
In order to run this servlet under JRUN (where X.X is replaced by the
version of JRUN you running):
- Make sure that amzi.dll and amzijni.dll are on the system PATH. (They are
both located in the amzi\bin directory). Alternatively, you can load these
libraries (and LSXs) explicitly in Java with Runtime.getRuntime().load(libraryPath)
or loadLibrary(libraryName).
- Copy the amzi\ls directory tree from amzi\lib\java20 to jrun\X.X\classes.
- Copy ExtPred.class and AmziPreds.class to jrun\X.X\jsm-default\services\jse\servlets
(or whatever directory you use to hold your servlets under JRUN).
- In your browser type, http://localhost/servlet/ExtPred
References
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