IF Computer > MINERVA > Example Programs > MINERVA Features > Servlet

Servlet

MINERVA
ifcomputer logo
f
Expert Services on the Web

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.

Running the Example

Follow these steps to install and run the example. The commands are given in UNIX/Linux conventions, adapt for other operating systems as needed.

  1. Install MINERVA and TOMCAT
    In the following we assume that MINERVA is installed at $MINERVA_HOME and Tomcat is installed at $CATALINA_HOME.

  2. Make a servlet directory
    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
    

  3. Copy HTML file to servlet directory
    cp minserve.html $CATALINA_HOME/webapps/minserve
    

  4. Copy MINERVA system files to the servlet directory
    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
    

  5. Copy servlet program to the servlet directory
    cp minserve.min $CATALINA_HOME/webapps/minserve/WEB-INF/minerva
    

  6. Compile the servlet program
    minervac minserve.min
    

  7. Restart the Tomcat server
    $CATALINA_HOME/bin/shutdown.sh
    $CATALINA_HOME/bin/startup.sh
    

  8. Invoke the servlet
    In a default installation of Tomcat, the URL will be http://localhost:8080/minserve/minserve.html

document: http://www.ifcomputer.co.jp/MINERVA/ExamplePrograms/MinervaFeatures/Servlet/print_en.html
published 2008/9/1 update 2002/3/19 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS