RE: [jade-develop] Passing arguments from JSP to JADE


Subject: RE: [jade-develop] Passing arguments from JSP to JADE
From: Bellifemine Fabio (Fabio.Bellifemine@TILAB.COM)
Date: Fri Dec 06 2002 - 17:02:57 MET


Looking at your code, I guess you are not using JADE 2.6 properly because since 2.6 the doStart method does not work like you are using it.
 
Since JADE 2.someversionbefore you also do not need to override the method setArguments (that is infact deprecated) but you can use directly getArguments(). I recommend you to read the programmer's guide, section 3.2.4, page 20, 'Agents with parameters ...'

I recommend you also to download JADE 2.61 (which is the latest version) and, in particular, the add-on of the JSP Tag Library where you can find a better example for using JADE from within a JSP page.

Like this:

<%@ taglib uri="jade.wrapper.taglib" prefix="jade" %>
<jade:container id="moncontainer" host="heron" port="1099"/>

<jade:useAgent id="snooper" classname="examples.jsp.Snooper" container="moncontainer" scope="application"/>

<% snooper.putO2AObject(request.getRemoteHost()+" "+(new java.util.Date())+" "+request.getRequestURI()+" METHOD 1",false); %>

<jade:useAgent id="snooper2" classname="examples.jsp.Snooper" container="moncontainer" scope="application"/>

<!-- BEWARE HERE: CR used to format the code are sent to the agent-->
<jade:sendObject id="snooper2" blocking="false"><%= request.getRemoteHost()+" "+(new java.util.Date())+" "+request.getRequestURI()+" METHOD2" %></jade:sendObject>
It works !!!!
Messages sent.
<%=snooper%>

> -----Original Message-----
> From: Bart Eeckhout [mailto:bart_eeckhout@hotmail.com]
> Sent: 03 December 2002 13:53
> To: jade-develop@sharon.cselt.it
> Subject: [jade-develop] Passing arguments from JSP to JADE
>
>
>
>
> Hi,
>
> I am a last year engeneering student working on a thesis
> called: Agents on
> the Semantic Web.
> I'm using a Jade (v2.6) agent-platform and JSP (with TOMCAT
> 4.0 server).
> My problem is the following:
> I have a JSP pages. This JSP page is used to start up a Jade
> agent. Until
> here no problem, but now I want to pass some arguments from
> the JSP-page to
> the agent that will be started in JADE.
> But this doesn't seem to work, the agent starts, but the
> arguments are
> denied.
> I already tried searching the internt, but i there doesn't
> seem to be very
> much information on this topic.
>
> I Use the following code:
>
> - The JSP page:
>
> <%@ page import="jade.core.*"%>
> <%!
>
> %>
> <jsp:useBean id="HelloWorldParam" class="agenten.HelloWorldParam"
>
> scope="application">
> <% try {
> String [] _args = new String [2];
> _args[0]= "-container";
> _args[1]= "-printing";
> jade.Boot.main(_args);
> System.out.println("Jade Inited()");
> System.out.println("Start");
> HelloWorldParam.doStart("HelloWorldParam");
> } catch (Exception ex) {
> out.println(ex);
> ex.printStackTrace();
> }
> %>
> </jsp:useBean>
> <HTML>
> <BODY>
> It works !!!!
> </BODY>
> </HTML>
>
>
>
> - The agent:
>
> package agenten;
>
> import jade.core.Agent;
>
> public class HelloWorldParam extends Agent {
>
>
>
> private String service;
>
>
>
> protected void setup() {
>
> System.out.println("Hello World. My name is "+this.getLocalName()+
>
> " and I provide "+service+" service.");
>
> }
>
>
>
> public void setArguments(String[] args) {
>
> service = args[0];
>
> }
>
> }
>
>
>
> -OUTPUT:
> Jade inited()
> Start
> Hello World. My name is HelloWorldParam and i provide null service.
>
>
>
> I hope someone can help me
> Thanx in advance
>
>
>
>
>
> _________________________________________________________________
> Ontvang je Hotmail & Messenger berichten op je mobiele
> telefoon met Hotmail
> SMS http://www.msn.nl/jumppage/
>
> _______________________________________________
> jade-develop mailing list
> jade-develop@sharon.cselt.it
> http://sharon.cselt.it/mailman/listinfo/jade-develop
> UNSUBSCRIBE INSTRUCTIONS AT
http://jade.cselt.it/mailing.htm#unsubscribe



This archive was generated by hypermail 2a22 : Fri Dec 06 2002 - 17:03:22 MET