wood burning stoves*
The moose likes Applets and the fly likes Sending an object to applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Sending an object to applet" Watch "Sending an object to applet" New topic
Author

Sending an object to applet

Sri Latha
Greenhorn

Joined: Jan 22, 2008
Posts: 10
Hello everyone,

I have to send an Object to Applet.
Can anyone tell how to do this?


Thanks and Regards,
Latha
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
Where does the object exist?


Ping & DNS - my free Android networking tools app
Sri Latha
Greenhorn

Joined: Jan 22, 2008
Posts: 10
HI,

I have a collection of strings in a vector in main() of java program.And i tried to send the object with in the params of an applet.Able to retrieve only first element of vector object.

So is there any other way to send the object to applet.

Thanks and Regards,
Latha.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
A param section like the following should work:

What does your param section look like?
Sri Latha
Greenhorn

Joined: Jan 22, 2008
Posts: 10
Hi,

Vector v = new Vector();
I have retrieved the result set from database.And i need to add that result set to vector
v.add(resultSetObjectValues);

<applet code=MultipleApplet.class width=400 height=350>
<PARAM name=vector value="+ v +">
</applet>

In the applet i am able to recieve only the first element of vector,though it contains many values.

Thanks and Regards,
Latha
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
An HTML file is text; you can't embed Java objects in it. You'll need to iterate through the vector and add elements one by one, so that you end up with a param section like the one I showed above. The "length" parameter tells the applet how many parameters to read.
Sri Latha
Greenhorn

Joined: Jan 22, 2008
Posts: 10
HI,

Is there any way to do with Socket connection to send the vector Object to applet.And can iterate that vector in applet.


Thanks and Regards,
Latha
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41182
    
  45
Yes, an applet can talk to a servlet using HTTP or serialization; see here for more information. (Note that serialization depends on both sides using the same JVM version, so unless you can dictate the JVM installed on the applet's users machines, this will likely not work.)

But what's wrong with writing parameters in a JSP? It's such an easy and straightforward approach, especially when compared with the alternatives.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending an object to applet
 
Similar Threads
Accessing Server Runtime from Applet
transfering objects to applets
why dose applets have init method and applications dont
Applet question - .class vs .java
Clock