• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP->Applet communication

 
yara becker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I am new in this issues so I hope you can help me.
I am developing a web application and I get some data from a database. Then I put this data in a java Vector. The problem is that I need to send this Vector to an applet and I don't know how.Could I send an ObjectStream to the applet or something like that?

Thanks in advance and sorry for my terrible English :-S
[ May 16, 2006: Message edited by: Bear Bibeault ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13077
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, a servlet can write an ObjectOutputStream and an applet can read it. Don't try this from a JSP because object streams must be binary.
Also, I suggest that you send an array, not a Vector, it will be simpler.
Note that Vector has a toArray method.
Bill
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Applet FAQ links to an example of Applet/Servlet communication using object streams.
 
yara becker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply!!!
But now I have another problem. I don't know how to explain. The Vector contains objects called "Question" but this objects are recognized in the server side and when I try to read the Vector in the Applet,a ClassNotFoundException is launched because Applet don't know what is a "Question", so I think I need another way to send this data to the Applet.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you add the Question class to the applet jar file?
 
yara becker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mm I think I can't do that because I have this situation: I have the client side with the "appletpackage.PrincipalApplet.class" and in the server side there other packages and Question class is part of one of them.So when I try to use readObject method it expect serverpackage.Question class.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An applet can consist of classes from whatever packages you like; they don't all have to be in the same one.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"subyara None",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff
 
yara becker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again!

Now my applet (various classes in two packages) don't recognize classes in secondary package.´┐ŻAny idea?


thanks again
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the Applets forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic