wood burning stoves
The moose likes Servlets and the fly likes Has anyone worked with Mobile Agents? (Servlet AND Mobile Agent) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Has anyone worked with Mobile Agents? (Servlet AND Mobile Agent)" Watch "Has anyone worked with Mobile Agents? (Servlet AND Mobile Agent)" New topic

Has anyone worked with Mobile Agents? (Servlet AND Mobile Agent)

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Have anyone implemented mobile agent before?
Also, have anyone tried integrading Servlet with Agents? Thanks

Thanks everyone who helped me
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
I have these notes from my servlets related URL collection
http://www.vistabonita.com/papers/DistributedComputingTopics.html - also AGLETS
http://www.vistabonita.com/papers/JMS/Introduction.html - paper on JMS
also the TACOS mobile agents in java
http://www.agentgo.com/aboutus.htm - mobile Java & XML wireless applications
Definately a cool topic - many books about "distributed computing" talk about mobile agents - servlets are a logical component since it should be easy for mobile agents to communicate via HTTP.
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
oh thanks.im a new baby on this topic
Have you tried them out?(Servlet+Agent)
I got many problem on this.
Also, can servlet help create a context for placing mobile agents? Or it can just help creating the agents? thanks
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Actually I had 1 servlet file and agent class created but can't work on Aglet2 yet (someone said the code can run on Aglet1.0.3 but I want to use Aglet2) the code and error is shown below, does anyone know how to overcome this? Thanks
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.ibm.aglet.*;
import java.net.*;
import com.ibm.aglet.system.*;
import com.ibm.aglet.event.*;
import java.sql.*;
public class example extends HttpServlet {
//Initialize global variables
public void init(ServletConfig config) throws ServletException {
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = new PrintWriter (response.getOutputStream());

AgletProxy Proxy = null;
String text = "";
String values[];

values = request.getParameterValues("textfield1");
if (values != null) {
text = values[0];

out.println("<body bgcolor=\"#FFFFFF\">");
out.println("<form name = \"form1\" method= \"post\" action = \"/user/servlet/example\">");
out.println("<tr><td>From User</td><td>From Aglet</td></tr>");
out.println("<td><input type=\"text\" name=\"textfield1\" value=\""+text+"\"></td>");


Proxy = null;
FutureReply reply = null;
Proxy = Aglets.createAglet("atp://",null,"sampleaglet1",null);
reply = Proxy.sendFutureMessage(new Message(text));
if (reply.isAvailable())
out.println("<td><input type=\"text\" READONLY name=\"textfield2\" value=\""+reply.getReply()+"\"></td>");
catch (Exception e)

out.println("<tr><td><input type=\"submit\" name=\"Submit\" value=\"Submit\"></td></tr>");
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
Starting service Tomcat-Standalone
Apache Tomcat/4.0.1
Starting service Tomcat-Apache
Apache Tomcat/4.0.1
[Reading security policy file:
E:\jdk1.4\jre\lib\security\java.policy... done.]
[Reading security policy file: E:\Documents and
Settings\shanemcmahon\.java.policy... done.]
[Loading shared secrets from file E:\Documents and
\security\secrets.dat ... file not found.]
No secrets.
Licensed Materials - Property of IBM
(c) Copyright IBM Corp.
1996, 1998 All rights reserved.
US Government Users Restricted Rights -
Use, duplication or disclosure restricted
by GSA ADP Schedule Contract with IBM Corp.
[IBM Aglets Class Library 2.1.0]
java.net.MalformedURLException: unknown protocol:atp
at java.net.URL.<init>(URL.java:398)
at java.net.URL.<init>(URL.java:323)
at java.net.URL.<init>(URL.java:318)
at java.net.URL.<init>(URL.java:253)
at java.net.URL.<init>(URL.java:274)
at com.ibm.aglet.Ticket.getDestination(Ticket.java:179)
at com.ibm.maf.atp.MAFAgentSystem_ATPClient.<init>(MAFAgentSystem_ATPClient.java:108)
at com.ibm.maf.atp.Handler.getMAFAgentSystem(Handler.java:113)

What problem it probaby is?Thanks
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
//sample aglet1
import com.ibm.aglet.*;
import com.ibm.aglet.event.*;
import java.io.*;
import java.util.*;

public class sampleaglet1 extends Aglet{

public boolean handleMessage(Message msg)
msg.sendReply("From Aglet : " + msg.getKind());
return true;
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63348

Dan Dales,
Your post was moved to a new topic.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
I agree. Here's the link: http://aspose.com/file-tools
subject: Has anyone worked with Mobile Agents? (Servlet AND Mobile Agent)
jQuery in Action, 3rd edition