This example shows how to use MINERVA as a servlet with Tomcat/Jakarta/Apache.
The servlet minserve takes some user information from an HTML FORM element, then echos the user information in HTML, XML or plain text.
The example shows how the MINERVA servlet predicates are called by FORM methods GET or POST, how to get the input parameters from the servlet request, build a Prolog term, convert it to the desired format and write it back to the servlet response to the HTTP client. Every step is logged to the server log.
The example has been prepared using the Jakarta Tomcat 3.2 and 4.0 servlet web servers by the Apache Software foundation, http://jakarta.apache.org/tomcat/index.html and Sun Java JDK1.4.
The example consists of the following files:
minserve.html - HTML file that contains the HTML FORM element.
minserve.min - MINERVA servlet program
web.xml - Tomcat control file that maps the servlet to its URL and tells Tomcat which MINERVA file it should load
A listing of the predicates provided by MINERVA is
servlet.mpk - servlet built-in predicates
These predicates correspond to their counterparts of the Java Servlet interface.
Follow these steps to install and run the example. The commands are given in UNIX/Linux conventions, adapt for other operating systems as needed.
mkdir $CATALINA_HOME/webapps/minserve mkdir $CATALINA_HOME/webapps/minserve/WEB-INF mkdir $CATALINA_HOME/webapps/minserve/WEB-INF/minerva mkdir $CATALINA_HOME/webapps/minserve/WEB-INF/classes
cp minserve.html $CATALINA_HOME/webapps/minserve
cp -r $MINERVA_HOME/com $CATALINA_HOME/webapps/minserve/WEB-INF/classes cp -r $MINERVA_HOME/servlet/WEB-INF/classes/com $CATALINA_HOME/webapps/minserve/WEB-INF/classes cp $MINERVA_HOME/minerva.mca $CATALINA_HOME/webapps/minserve/WEB-INF/minerva cp $MINERVA_HOME/servlet/WEB-INF/minerva/servlet.mpk $CATALINA_HOME/webapps/minserve/WEB-INF/minerva
cp minserve.min $CATALINA_HOME/webapps/minserve/WEB-INF/minerva
minervac minserve.min
$CATALINA_HOME/bin/shutdown.sh $CATALINA_HOME/bin/startup.sh