permaculture playing cards*
The moose likes Applets and the fly likes Applet to Servlet Communication 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 "Applet to Servlet Communication" Watch "Applet to Servlet Communication" New topic

Applet to Servlet Communication

Nathalie Doremieux

Joined: Oct 16, 2001
Posts: 2
I am trying to send a Vector from an applet to a servlet.
I have no problem with IE. But it doesn't work with Netscape(4.7x & 6.x).
Any example would be great.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959

How are you sending it? If you're serializing, you could be having problems with differing versions of serialization between the client and server.

Customer surveys are for companies who didn't pay proper attention to begin with.
Nathalie Doremieux

Joined: Oct 16, 2001
Posts: 2
Here is what I am using to send the Vector:
URL url = new URL(getDocumentBase(),
URLConnection urlconnection = url.openConnection();
urlconnection.setRequestProperty("Content-Type", "multipart/form-data");//Netscape Bug
ObjectOutputStream objectoutputstream = new ObjectOutputStream(new GZIPOutputStream(urlconnection.getOutputStream()));
System.out.println("trying to send");
Vector objs = new Vector();
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959

writeObject is part of the serialization mechanism, so it's likely that your sending serializer is incompatible with your receiving serializer. A better bet is to simply send everything as text:

where convertToObject() is a method you write to undo the "toString" on the sending side (if desired).
An industrial-strength version might send the vector size as a number on the first line (preceeding the data lines) so you can optimally preallocate the Vector (or use an Array object, which is faster).

[This message has been edited by Tim Holloway (edited October 17, 2001).]
I agree. Here's the link:
subject: Applet to Servlet Communication
Similar Threads
Servlet to applet communication
how to download file from server?
from a applet how can i call a servlet??
Servlet and Applet Communication
Redirect from servlet to html (or php) web?