Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Iam stuck...please help me...

 
Sathish Babu Adluru Subas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi javacs,
My app is a distributed app.My server app has a class called cmsborrower which can store array of objects.it has 3 variables like code,name & sex.what my server app does is that it retrives the info from the DB and writes it to cmsborrower object.The prob that iam stuck to is that iam not able to retrive the info from the object of type cmsborrower in the Client app.
the skeletal code is...
server app
----------
public class cmsborrower
{
public String code;
public String name;
public String sex;
}
...
resobject.writeObject(cbm)
//here : cbm = instance of cmsborrower
resobject = instance of ObjectOutputStream
client app
----------
public class receive
{
cmsborrower[] cbm = new cmsborrower[10];
}
...
receive rec = new receive();
rec.cbm = (cmsborrower[])resobject.readObject();
//here resobject - instance of ObjectOutputStream class
If iam trying to print the result like :
System.out.println("Values :- " + rec.cbm[i].code + " | " + rec.cbm[i].name + " | " + rec.cbm[i].sex);
iam getting exceptions that i couldn't even read what it is...
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like a confusion between the client an server. In your server code you say:

resobject.writeObject(cbm)
//here : cbm = instance of cmsborrower

ie. You are sending a single object instance.
In your client code you say:

rec.cbm = (cmsborrower[])resobject.readObject();

ie. you are expecting to receive an array of object instances. Your cast to (cmsborrower[]) is successful, but as soon as you try to access any of the elements it throws an exception, as you haven't really got an array there.
 
Sathish Babu Adluru Subas
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx for ur reply. but my client side's cbm is also instance of cmsborrower[].sorry that i've posted it wrongly.some more help would do a world of good...please...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!