Marcos Lloret <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
07.07.2000 10:04

To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
cc:
bcc:
Subject: applets, servlets (communication)


hi,

   i want to pass some parameters (strings, matrix, ...) into a
servlet.
   how can i do it?  Is the same way to send parameters between
applets?

thanks in advance,

marcos

Hello,

 

You can use ObjectInputStream and ObjectOutputStream. Your classes must implement the Serializable interface.

 

Write the following Code in your Applet:

 

URL url = new URL("http://....");

HttpConnection con = (HttpConnection) url.openConnection();

out = new ObjectOutputStream(con.getOutputStream());

out.writeObject(out);

out.flush();

// It MUST get an input stream.

// Otherwise, no data are send to the servlet

// Bug or feature ??

con.getInputStream();

out.close();

 

put the following code in the doPost method of your Servlet

 

ObjectInputStream in = new ObjectInputStream(request.getInputStream);

Object object = in.readObject();

 

To send data from the Servlet to the Applet works vice versa with resonse .

 

Sven Daumann

 

 


---------------------------------------------------------------------- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to