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
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
Author

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

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Hi,
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
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
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.
Bill
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
code:
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 {
super.init(config);
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
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("<html>");
out.println("<body bgcolor=\"#FFFFFF\">");
out.println("<form name = \"form1\" method= \"post\" action = \"/user/servlet/example\">");
out.println("<table>");
out.println("<tr><td>From User</td><td>From Aglet</td></tr>");
out.println("<tr>");
out.println("<td><input type=\"text\" name=\"textfield1\" value=\""+text+"\"></td>");


try
{

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

out.println("</tr>");
out.println("<tr><td><input type=\"submit\" name=\"Submit\" value=\"Submit\"></td></tr>");
out.println("</table>");
out.println("</form>");
out.println("</body>");
out.println("</html>");
out.close();
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
--
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
Settings\shanemcmahon\.aglets
\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
Marshal

Joined: Jan 10, 2002
Posts: 60780
    
  65

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)
 
Similar Threads
I need help urgently
Part II - Securing web & gui apps
Programming for clusters
Grouping servlets
Inspecting Java Processes within the JVM