Java/JSP/Servlet Interface |
![]() |
The Java interface can be used to build both web-based and stand-alone applications. It consists of 9 files. The first 5 files are in the arulesxl\api\bin_redist directory. The last 4 files are in the arulesxl\api\java directory.
To use the Java interface you need to:
Java method names start with a lowercase letter.
Description:
Vector queryRulesToStringList(String ruleset, String query) throws Exception
Remarks:
Queries the named ruleset and returns the result as a Vector where each element in the vector is an array of Strings.
Return Value:
The result of the query as a Java Vector where each element is a Java String[].
Throws an exception on failure.
Example:
out.println("<hr><h2><font color=blue>Vaccination Retrospective Analysis</font></h2>");
Vector history = arxl.queryRulesToStringList("vaclogic", "FIND history");
out.println("<p><table border=1 cellpadding=2><tr><td><b><font color=navy>Vaccination</font></b></td><td><b><font color=navy>Dose</font></b></td><td><b><font color=navy>Date Given</font></b></td><td><b><font color=navy>Status</font></b></td><td><b><font color=navy>Comment</font></b></b><td><b><font color=navy>Age Given</font></b></td></font></td></tr>");
for (i = 0 ; i < history.size() ; i++) {
out.println("<tr>");
if (!(history.elementAt(i) instanceof String)) {
String[] row = (String[]) history.elementAt(i);
for (j = 0 ; j < row.length ; j++) {
if (row[j] == null || row[j].length() == 0)
out.println("<td> </td>");
else
out.println("<td>" + row[j] + "</td>");
}
}
out.println("</tr>");
}
out.println("</table></p>");
The method GetLS() returns a LogicServer object that you can use with any of the Logic Server methods as documented in the Amzi! Logic Server Reference Guide.
There are two samples that use the 'Product Advice.xls' sample. One is a standalone Java application. The other is a Java servlet. They have the same inputs and outputs.
First install the Java interface as outlined above. Then:
javac Advice.java
To run the sample:
java Advice
Enter a value for swing speed, optionally select other choices from the pull-down menus and press 'Go'.
First install the Java interface as outlined above. You must configure your server (e.g. Tomcat) so it can find the amzi.* classes at runtime. Then edit 'AdviceServlet.java' and change the value of ARULES_DIR and FORM_URL to correspond to your system. Put advice.axl and the rest of the install files in ARULES_DIR. To compile:
javac AdviceServlet.java
A sample web.xml file is provided in the WEB-INF directory. Running the servlet depends on your environment, but in general, a URL of this form is used (assuming the servlet is installed in a directory named 'advice':
http://localhost:8080/advice/AdviceServlet
Enter a value for swing speed, optionally select other choices from the pull-down menus and press 'Go'.
|
Copyright ©2005-7 Amzi! inc. All Rights Reserved.
|