EOFException with Servlet and serialization
Hi,
I've got a problem using serialization with a servlet. I need to serialize an object and send it to a servlet which will deserialize it. I'm having the folowing exception :
java.io.EOFException
at java.io.DataInputStream.readFully(DataInputStream.java:158)
at java.io.ObjectInputStream.readFully(ObjectInputStream.java:2071)
........
Client code
-
// connects to the servlet
URL url = new URL("http", host, Integer.port, servlet);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setDefaultUseCaches(false);
connection.setRequestProperty("Content-Type", "application/octet-stream");
// write to stream
ObjectOutputStream oos = new ObjectOutputStream(connection.getOutputStream());
oos.writeObject(record);
oos.flush();
oos.close();
Servlet code
ObjectInputStream ois = new ObjectInputStream(request.getInputStream());
logRecord = (LogRecord)ois.readObject();
ois.close();
Any ideas ? Thanks.
Antonio

