Hi,

I am trying to send a serialised object to a java servlet. I am using JRun 2.3
on NT 4.0.
The applet code is:

  try
  {
   URL servletURL = new URL("http://s_webdev2/servlet/EmailServlet");
   URLConnection servletConnection = servletURL.openConnection();
   ObjectOutputStream outputToServlet;

   /* Inform the connection that we will send output and receive input */

   servletConnection.setDoOutput(true);
   servletConnection.setDoInput(true);

   /* Don't use a cached version of URL Connection */

   servletConnection.setUseCaches(false);
   servletConnection.setDefaultUseCaches(false);

   /* Set the content that we will be sending binary data */

   servletConnection.setRequestProperty("Content-Type",
"application/octet-stream");

   outputToServlet = new
ObjectOutputStream(servletConnection.getOutputStream());

   /* Serialise the object */

   outputToServlet.writeObject(emailSerialisedObject);

   /* Actually send the object now */

   outputToServlet.flush();
   outputToServlet.close();
  }
  catch(MalformedURLException mfurle)
  {
   System.out.println("Error sending serialised Object was mfurle" +
mfurle.getMessage());
  }
  catch(IOException ioe)
  {
   System.out.println("Error sending serialised Object was ioe " +
ioe.toString());
  }
 }

The servlet code is:

public synchronized void doPost(HttpServletRequest req, HttpServletResponse
res)
 {
  try
  {
   ObjectInputStream inputFromApplet = new
ObjectInputStream(req.getInputStream());

   EmailSerialisedObject emailObject = (EmailSerialisedObject)
inputFromApplet.readObject();

   inputFromApplet.close();
  }
  catch(Exception e)
  {
   log("Error from servlet was " + e.getMessage());
  }
 }

where  EmailSerialisedObject is my object which implemented Serializable
interface.

please help!!

thanks in advance

gerardo
begin:vcard
n:Macari;Gerardo
tel;work:Corel Europa House Hartcourt st, Dublin (Ireland)
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:[EMAIL PROTECTED]
fn:Gerardo Macari
end:vcard

Reply via email to