Next Previous Contents

2. Configuration

2.1 Preferences

A valid Java 2 runtime environment has to be installed on the machine, where the Pi3Web is installed as a Servlet engine. This could be done by installing either the JDK 1.2.2 or the JRE 1.3.1. Both are available as download packages from the SUN web site.

The Pi3Web 2.0 package for Win32 has to be installed and the WebServer should be ready to use so far.

2.2 Quick Start for Windows NT

  1. The Pi3Web server should be stopped.
  2. Unzip the Pi3Servlet-x86Win32-2_0_0-beta2.exe archive from Sourceforge or the Pi3Web website.
  3. Run the installer and adjust the path to your Pi3Web installation folder (usually c:\Pi3Web).
  4. Optionally adjust the JvmOption java.class.path and the JvmOption java.library.path in Servlet.cnf accordingly to your JDK/JRE installation-
  5. Start your server using the Servlet.pi3 configuration i.e. from the command line by typing Pi3 ../Conf/Servlet.pi3 when your current directory is ./bin.
  6. Try to call the following test page and to run the Servlet tests.

2.3 Details

Contents of Servlet package

The archive Pi3Servlet-x86Win32-2_0_0-beta2.exe contains:

The above listed path names are relative to your Pi3Web installation folder.

Configuration settings

Servlet Container parameters

Servlet/JSP parameters

Currently Servlet and JSP objects share the same configuration parameters.

This is a simplified example of Servlet.cnf:


        <Library>
                Name Servlet
                POSIXPath ./libServlet.so
                Win32Path Servlet.dll
        </Library>
 
        <Class>
                Name ServletContainerClass
                Type LogicExtension
                Library Servlet
                OnClassLoad ServletContainer_onClassLoad
                Constructor ServletContainer_constructor
                CopyConstructor ServletContainer_copyConstructor
                Destructor ServletContainer_destructor
                Execute ServletContainer_execute
        </Class>
 
        <Object>
                Name ServletContainer
                Class ServletContainerClass
                JvmNumber 1
                JvmOption "-Djava.compiler=NONE"
#               JvmOption "-verbose:jni"
                JvmOption "-Djava.class.path=servlet.jar;Pi3Servlet.jar"
                JvmOption "-Djava.library.path=."
#               JvmIgnoreUnrecognized
                JvmLocalReferences 128
                LogFile "../Logs/servlet.log"
                Expression "[$t|$P|$k|$T] "
                OpenMode "a"
                DocBase ".\WebRoot"
        </Object>
 
        <Class>
                Name ServletClass
                Type LogicExtension
                Library Servlet
                OnClassLoad HandlerBaseServlet_onClassLoad
                Constructor Servlet_constructor
                CopyConstructor HandlerBaseServlet_copyConstructor
                Destructor HandlerBaseServlet_destructor
                Execute HandlerBaseServlet_execute
        </Class>
 
        <Object>
                Name Servlet
                Class ServletClass
                Context ServletContainer
        </Object>
 
        <Class>
                Name JspClass
                Type LogicExtension
                Library Servlet
                OnClassLoad HandlerBaseServlet_onClassLoad
                Constructor Jsp_constructor
                CopyConstructor HandlerBaseServlet_copyConstructor
                Destructor HandlerBaseServlet_destructor
                Execute HandlerBaseServlet_execute
        </Class>
 
        <Object>
                Name Jsp
                Class JspClass
                Context ServletContainer
        </Object>
 

This is a simplified example of Servlet.pi3:


#!../bin/Pi3
 
include ../Conf/Servlet.cnf
 
<Object>
        Name Start
        Class FlexibleHandlerClass
        ...
        Mapping Condition="&regexp('*/servlet/*',$U)" ServletMapper \
From="/servlet/" To="/servlet/"
        ...
</Object>
 
<Object>
        Name HTTPLogicObject
        Class HTTPDispatcherClass
        ...
        Handlers Start Scripts WinScripts FastCGIScripts Servlets Default
        ...
</Object>
 
<Object>
        Name Servlets
        Class FlexibleHandlerClass
        Condition "&cmp(&dblookup(response,string,ObjectMap),Servlet)"
        CheckPath ReturnCode ReturnCode=COMPLETED
        CheckAccess ReturnCode ReturnCode=COMPLETED
        CheckType ReturnCode ReturnCode=COMPLETED
        Handle Condition="&regexp('*/SessionServlet*',$z)" Servlet ClassName="org.pi3.servlet.samples.SessionServlet"
        Handle Condition="&regexp('*/DispatchServlet*',$z)" Servlet ClassName="org.pi3.servlet.samples.DispatchServlet"
        Handle Condition="&regexp('*/org.pi3.servlet.samples.*',$z)" Servlet Init="Key1=Value1" Init="Key2=Value2"
</Object>
 
<Object>
        Name ServletMapper
        Class PathMapperClass
        CaseSensitive "No"
        PathInfo "Yes"
        Action "&dbreplace(response,string,ObjectMap,Servlet)"
</Object>

Enhanced tips

2.4 Development Environment

To build the source packages it is important to adjust the respective settings with yourd JDK paths. This is also required to change the development environment from one JDK version to another.

Win32

Open the "Properties" dialog of the MSVC projects Servlet.dsp and ServletJNI.dsp. Adjust the path settings for the compiler include and linker library search paths in accordance with your JDK installation.

Linux

Either set the required environment in your shell profile or run make in the ./Source/Servlet directory with the following trailer:


#!/bin/sh
export JAVA_HOME=/usr/local/jdk1.3.1
export CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/jre/lib/Pi3Servlet.jar:\
$JAVA_HOME/jre/lib/servlet.jar
export LD_LIBRARY_PATH=.:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/Server:\
$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/native_threads:$LD_LIBRARY_PATH
make

2.5 Troubleshooting

Most problems arise due to incorrect Java CLASSPATH settings. Dependant on the the affected Java classes there will be corresponding startup or runtime problems.

General you've a number of options to detect the reason of a certain problem:

Because the server starts an own JVM (Java Virtual Machine) with an own environment, which is configured in Servlet.cnf, the machine's original Java runtime environment settings aren't relevant.

The server won't startup using Servlet.pi3

Some of the probably errors at startup time are


export JAVA_HOME=/usr/local/jdk1.3.1
export LD_LIBRARY_PATH=.:$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/Server:\
$JAVA_HOME/jre/lib/i386/native_threads:$LD_LIBRARY_PATH

The server won't process a certain Servlet URL

Some of the probably errors at request time are

Other problems


JvmOption "-Xms16384kB"
JvmOption "-Xmx32768kB"


Next Previous Contents