Eofexception While Constructing An Objectinputstream
Solution 1:
The servlet has got an exception of some kind and hasn't even constructed the ObjectOutputStream. You need to check the response code for 200 before you try to construct the ObjectInputStream at the client.
Solution 2:
Some crazy idea... try to add a Content-Length
header to your response. Could imply writing your bytes to a ByteArrayOutputStream, measuring the size, setting the header and only then writing to response... but could be the reason that URLConnection is prematurely cutting the connection...
ByteArrayOutputStreambaos=newByteArrayOutputStream();
ObejctOutputStreamoos=newObejctOutputStream(baos);
oos.write(...);
byte[] data = baos.toByteArray();
response.setHeader("Content-Length", "" + data.length);
response.getOutputStream().write(data);
Java Serialization
@Robert comment is right. Java serialization is not intented for communication between different environments. More if you're working between JVM and Dalvik. So another framework would be more suitable (something with XML or JSON could be nice, even wrapping it with a GZip[]Stream).
Post a Comment for "Eofexception While Constructing An Objectinputstream"