AgentScape Servlet Service

This sections contains information about the Servlet service. This service allows agents to publish servlets, which allow interaction with the agent through a web browser. It can be installed as an additional component using the AgentScape installation program.

The project consists of 3 modules that each implement part of the functionality.

Servlet service

The servlet service allows clients (agents or services) to publish servlets. Agents cannot open an HTTP port manually, but it can open a connection to the central servlet server.

The servlet service itself can be accessed via HTTP using a web browser. The service maintains a number of (AOS socket) connections from client agents. As soon as a request for a given agent servlet comes in, the request is forwarded to the appropriate agent, which handles the details of the request. As soon as the agent has finished processing the request, the response is handed back to the service, which writes the response back over the HTTP connection.

The entire servlet processing is done inside the agent, so the servlet can reflect all internal state from the agent that is required. The servlet service merely maintains the connection to the outside world (via HTTP) and takes care of aggregating all clients. This means that the servlets from all agents can be accessed from a single (central) point.


By default, the servlet service listens on port 8008. However, if you want to change this, you can configure the servlet service using the configuration GUI and setting the port argument to another value. Manually changing the XML configuration can be done as well:

<argument name="port" value="8008"/>

Servlet access

Because many agents can run on different machines, the benefit of a single servlet service is that it has the ability to aggregate servlet information from many agents (on many hosts). Even after the agent has migrated to a new location, the servlets may still be accessed from the same (central) servlet service.

Usually, it is easiest to have a well-known location where servlets from different agents can be accessed from. If there is only a single servlet service running with WORLD access mode, the servlets of all agents can be viewed from here. Note that it does not matter where the actual agent is located, or whether it has migrated or not: the servlet service takes care of forwarding requests to the specific the agent.

Servlet library

To use the servlet service, a client needs to use the servlet client library provided by the service. This implements the API to connect and interact with the servlet service. The library takes care of connecting to the servlet service. To use the library from a maven client project, it needs to use the correct dependency


The library has a simple API:

  public void setName (String name);
  public void publishServlet (HttpServlet servlet, String path);

The setName() method serves as a small helper to provide an alias for your agent. Setting a name for a client allows the servlets for an agent to be accessed via http://server:port/Name/YourAgentName

Servlet client agent

The client agent demonstrates how to use the service to publish a servlet. These servlets can be viewed by browsing to the HTTP locations of the servlet service. The default address is http://localhost:8008 (on the machine that runs the Host JVM).

If no agents are connected, this page does not show any information. For each agent that is connected to the service, an entry with a link is shown. Clicking on the link will show an overview of all the servlets that the agent has published. As soon as the user clicks on one of these agent servlet links, the servlet that runs inside the agent is activated.

The servlet client agent publishes 2 servlets: a “hello” servlet and a demo servlet which provides some buttons & input to test GET and POST requests. As soon as the agent vanishes, its links can no longer be accessed.

Built-in Servlets

When connecting to the servlet service, it shows a number of built-in servlets which are provided by the servlet service itself (not by any agent). At the moment, the following servlets are available:

  • DirectoryService servlet: allows to inspect the contents of the directory service.
development/service/servlet_service.txt · Last modified: 2012/05/15 14:16 by reinier