aspose file tools*
The moose likes Distributed Java and the fly likes how to pass value one program to another program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "how to pass value one program to another program" Watch "how to pass value one program to another program" New topic
Author

how to pass value one program to another program

saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
Hello sir,
i hardly try to pass the value from one java program to another java program please give some idea

my problem

i have one java program that will get callerid using this
String callerid=request.getCallerId(); i want to pass this callerid to another java program Note (i am not using package)

using this i calling another program

Class b=Class.forName("English01");
Object obj1=b.newInstance();
English01 f=(English01)obj1;
f.service( request,channel);


how to do that if you have idea or same code please guide me
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
Can you give us an idea of your distributed environment?

What are these objects you just mentioned? e.g. are they servlets, ejbs, etc.

What is the component type of the caller, and the called object?

Are they on the same machine?

Etc.
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
hi, thanks for your reply. Yes in the same machine i have two java program in same directory

program A

Having callerid that callerid i have to send to program B

program A call program B using

Class b=Class.forName("program B");
Object obj1=b.newInstance();
program B f=(program B)obj1;
f.service( request,channel);

when i calling this program B my callerid also have to send to program B from program A how to do that please guide me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41509
    
  53
So these are are two standalone applications, each running in their own JVM?

You could use sockets; see here for an introduction. RMI is also an option, although it may be overkill for your purposes.


Ping & DNS - my free Android networking tools app
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
You posted in 'Distributed Java'.

I am still not sure what your environment is.

It could be Spring. It could be plain java classes. Etc.

If you passed Request and it contains the callerid data, then you essentially have passed the callerid too. Just get the callerid from the request object in the called program.
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
thanks for your reply can you give any idea how to get that callerid? I using this request String callerid=request.getString(newcallerid); but its not working showing error


cannot find symbol
symbol : variable newcallerid
location: class MLogoff_Calleridin
String callerid=request.getString(newcallerid);
can you help me
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
hi, thanks for yr reply

this is my code:

public void service(AgiRequest request, AgiChannel channel)
throws AgiException
{
//here i getting callerid
String callerid=request.getCallerId();

System.out.println(callerid);
if(callerid!=null)
{

int call=callerid.length();

if(call>3)
{
//i truncated the callerid i have to pass newcallerid value to another program
newcallerid=(callerid.substring(call-3,call));

System.out.println(newcallerid);
}
else
{
newcallerid=callerid;
}

try
{

Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/campaign", "meetme", "meetme");
st = conn.createStatement();
rs5=st.executeQuery("select * from customerdetails where telno='"+ newcallerid +"' || mblno='"+ newcallerid +"'");
if(rs5.next())
{

try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/inboundcrm", "meetme", "meetme");
st = conn.createStatement();
rs3=st.executeQuery("select * from queue where loginflag=0");
if(rs3.next())
{
System.out.println(newcallerid);

//this below i calling another program

Class b=Class.forName("MLogoff_Calleridin");
Object obj1=b.newInstance();
MLogoff_Calleridin f=(MLogoff_Calleridin)obj1;
f.service( request,channel);

}//if close
}catch
}
}
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
It looks like you forgot to set (or put, whatever you call it) the newcallerid data into the request object.

You did this,

newcallerid=callerid;

but where in the code did you put the newcallerid data into the request object?

No wonder the receiving program cant find it.
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
thank your very much.what you said correct my problem is i don't know how to put that newcallerid data into the request object and how to get that value in another program using core java? if servlet means i can do using session but in core java how to do please guide me
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
AgiRequest is the class.

You need to know how to do what you want on that class.

E.g. you need to know what method in the AgiRequest class is used to put data into the AgiRequest object instance.

Some of the ways you can do this are:
-You can refer to your company's documentation.
-You can also use an IDE which tells you what are the methods in the class.
saravanan rajendran
Ranch Hand

Joined: Jun 13, 2008
Posts: 75
thanks for your help but its not coming for me i don't have that much knowledge to understand you but i tried like this not coming please guide me

request object given like this
String newcallerid=request.getParameter(newcallerid);in program A

String callerid=request.getString(newcallerid);in program B

how to give request and response object?
Jesus Angeles
Ranch Hand

Joined: Feb 26, 2005
Posts: 2053
You have to know what AgiRequest class has, e.g. its methods.

I wouldnt know as that only exists in your company. It doesnt come out in google.

You have to get that information.
aleem khan
Ranch Hand

Joined: Aug 07, 2008
Posts: 94
can you try this?(eclose newcallerid with double quotes "")

String newcallerid=request.getParameter("newcallerid");in program A

String callerid=request.getString(newcallerid);in program B


SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass value one program to another program