Bernadette--

You can always use Serialization to send an object across any type of
Input/Output stream:

Serializable obj = ...;
    // any Serializable-implementing object instance

OutputStream os = ...;
    // maybe os is from socket.getOutputStream()? FileOutputStream? doesn't
matter

ObjectOutputStream oos = new ObjectOutputStream(new DataOutputStream(os));
oos.writeObject(obj);

// On the recipient end
InputStream is = ...;
ObjectInputStream ois = new ObjectInputStream(new DataInputStream(is));
Serializable obj = (Serializable)ois.readObject();

// Now cast 'obj' to whatever

That, at least, sends the object across the wire. Note that the object's
class has to be present in both JVMs to work, though.

See the Object Serialization Specification on the Javasoft site or the
Serialization examples in the JDK 1.1 or 1.2 download bundles for more
examples.

Ted Neward
Patterns/C++/Java/CORBA/EJB/COM-DCOM spoken here
http://www.javageeks.com/~tneward
 "I don't even speak for myself; my wife won't let me." --Me

-----Original Message-----
From: Bernadette K. Minton <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Sunday, June 20, 1999 1:46 AM
Subject: Servlet/Applet communication


>Hi!
>
>I have just started writing Java servlets and applets, and would like to
>know if anyone has a pointer to some sample code that does the following:
>
>An applet running in a browser communicates with a servlet, requesting
>information from a database
>The servlet retrieves the info from the database, packages it up as an
>object, and sends the object to the applet.
>The applet then uses the information in the object to conditionally display
>graphics, to display some of the text information obtained from the
>database, etc.
>
>I have found a sample servlet on an HP site that has JDBC Gateway
>functionality which allows an applet to specify an SQL query to the
>servlet.  Other samples would be appreciated.
>I would also like to see a sample for how to send the information from the
>servlet to the applet as an object.
>
>Bernadette
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to