[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] java.io.StreamCorruptedException




Hi all.

I'm trying to call a servlet from  my application and get a binary
object.
    But get java.io.StreamCorruptedException: InputStream does not
contain a serialized object  in "readObject()" method

Client code:

    System.getProperties().put("java.protocol.handler.pkgs",
"iaik.protocol");
    String query = new String("https://myhost/servlet/myservlet");
    query = query + "?param1=&param2=value2&param3=&param4=&param5=";

   URL url = new URL(query);
   HttpsURLConnection servletConnectionS =
(HttpsURLConnection)url.openConnection();

  servletConnectionS.setRequestMethod("POST");
  servletConnectionS.setDoInput(true);
  servletConnectionS.setDoOutput(true);
  servletConnectionS.setUseCaches (false);
  servletConnectionS.setDefaultUseCaches (false);

servletConnectionS.setResponseProperty
("Content-Type","application/octect-stream");

  //* *******************************************************
   ¡¡¡¡¡¡¡¡¡    Without this line, connection is not stablished. With
getInputStream only doesn't work ¡¡¡¡¡¡¡¡
  ********************************************************//
  ObjectOutputStream oss = new
ObjectOutputStream(servletConnectionS.getOutputStream());

  ObjectInputStream ois = new
ObjectInputStream(servletConnectionS.getInputStream());
    byte [] b = (byte [])ois.readObject();
    ois.close();
  oss.close();

   servletConnectionS.disconnect();

In the server side:

  //***************
    bytes are correcty send
***************//
   res.setContentType("application/octect-stream");
   toClient = res.getOutputStream();
   toClient.write(s.getBytes());
   toClient.flush();
   toClient.close();


Thanks in advance, Gabi

--
Gabriel López Millán
Facultad de Informática -Universidad de Murcia
30001 Murcia - España (Spain)
Telf: +34-968-364644 E-mail: gabilm@dif.um.es



--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-ssl