Shipping Advisor JSP Sample
This example adopts shipping advisor to Java Server Pages. The source code is
in:
- shipPageBean.java - This Java bean encapsulates calling the Amzi! Logic
Server to load ship.xpl and get the list of shipping options from the user's
requirements. It is in a package named 'ship'.
- shipPage.jsp and shipErrorPage.jsp - The Java Server Page that invokes
ship.shipPageBean.class.
- ship.pro - The logicbase that finds all possible shipping options for a
set of inputs.
Building the Sample
To build the sample:
- Build ship.xpl by compiling and linking ship.pro.
- Change the pathname in shipPageBean.java for the call to ls.Load to match
your webserver (see below).
- Build shipPageBean.class by compiling shipPageBean.java with javac
- Organize the files into the proper directories for your JSP/web server
software. You will also need to put amzi.dll and amzijni.dll (Windows) or
libamzi.so and libamzijni.so (Unix) where the JSP/web server can find it.
Running the Sample
Tomcat
Tomcat generally installs in a directory named Apache Group/Tomcat X.X.
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 Group/Tomcat X.X/webapps named
'ship'.
- Copy the amzi/samples/internet/jsp/ship/WEB-INF subdirectory tree to ...Tomcat
X.X/webapps/ship.
- Create a directory named 'classes/ship' under the 'WEB-APPS' subdirectory
resulting in ...Tomcat X.X/webapps/ship/WEB-INF/classes/ship.
- Copy shipPageBean.class to ...Tomcat X.X/webapps/ship/WEB-INF/classes/ship.
- Copy ship.xpl to ...Tomcat X.X/webapps/ship (this pathname should
match the one you edited into shipPageBean.java under 'Building the Sample').
- Copy amzi.dll, amzijni.dll (from amzi/bin) to ...Tomcat X.X/webapps/ship/WEB-INF/classes.
Alternatively, you can load these libraries (and LSXs) explicitly in Java
with Runtime.getRuntime().load(libraryPath) or loadLibrary(libraryName).
- Copy the entire amzi/ls subdirectory tree (from amzi/lsapis/java20) to ...Tomcat
X.X/webapps/ship/WEB-INF/classes (so you now have the Logic Server
.class files in Tomcat X.X/webapps/ship/WEB-INF/classes/amzi/ls).
- Stop and restart Tomcat.
- In your browser type, http://localhost:8080/ship/shipPage.jsp. Fill in the
prompts and press the button.