I am trying to send a serialized object from a JSP to another servlet
through HTTP, but I keep running into an invalid stream header
exception. My theory is that the servlet is (for some reason or
another) not reading the whole serialized object. I have tried placing
logging statements at different stages of the serialized object. If I
specify the Content-Length of the serialized object more logging
statements show up, but I still run into the invalid stream header
problem. Am I missing something critical? Has anybody else seen this
(or a similar) problem before?
Cheers,
Eric Czarny
Esmond Pitt - 01 Dec 2007 01:06 GMT
> Has anybody else seen this
> (or a similar) problem before?
This is usually caused by different lifetimes of the ObjectOutputStream
and ObjectInputStream on one side or the other when sending multiple
objects. You need to use one of each for the life of the connection, and
make sure you flush & close the OOS, not the stream it encloses.