AgentBase   AgentBase for SICStus
Components for Internet Programming
Version 2001-0.2-alpha

AgentBase Home > examples: jeval/multi_eval.pl

  OVERVIEW
  Introduction
Download
Installation
FAQ

  EXAMPLES
  Web Server + CGI
Prolog + Java
Prolog + Java Applets
Applet Logic Monitor
Query-Eval via Telnet

  COMPONENTS
  Generic Server
HTTP Support
HTML Support
JEval Java Interface
Utilities

  RELATED
  SICStus Prolog Home
AgentBase 0.1-alpha


Page Formatted for Printing

Example - Jeval - multi user GUI

This is a simple example of communication between Java and Prolog where Prolog is the server and a Java applet is client. In this example multiple applets can access the same Prolog application.

Instructions

1. Change directory to examples/jeval/ and start the example with

sicstus -l multi_eval

Normally the server will listen for http at port 30002.

2. Browse to http://localhost:30002/

Each time a browser access the server it will send a page with a Java applet. The applet then "logs-in" to the server and request the application dependent Java code (BeanShell scripted). In this example it is the application dependent code describes a GUI:

   jeval:jeval(User, '\c
               jevalApplet.setLayout(new GridLayout(0,1));\c
               jevalApplet.add(new Label("Enter expression"));\c
               expr = new TextField("5 * 7");\c
               jevalApplet.add(expr);\c
               result = new Label("Result:");\c
               jevalApplet.add(result);\c
               button = new Button("Evaluate!");\c
               jevalApplet.add(button);\c
               jeval.addActionListener("button");\c
               jeval.addActionListener("expr");\c
               jevalApplet.validate();\c
               jevalApplet.repaint();').

When you have successfully started the multi_eval example and browsed to the server you will see a small applet looking like the screenshot below.

Source Code

The code of the Jeval example multi_eval.pl.

Copyright © 2001 SICS AB, All Rights Reserved.
For more information about AgentBase please email agentbase@sics.se.