• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

how to pass value one program to another program

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jesus Angeles
Ranch Hand
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic