hi,
maybe you need to set the content type before writing the object:
res.setHeader("CONTENT_TYPE", "application/octet-stream");
-mw
----- Original Message -----
From: "Harinath D.P" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, November 09, 2001 1:25 PM
Subject: Re: StreamCorruptedException: Header out of range 124
Hello all,
I am posting the piece of code
Thx.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The object i am trying to send is this
import java.io.*;
public class DataTransfer implements Serializable {
String data = new String();
public void setData(String str) {
this.data = str;
}
public String getData() {
return data;
}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Servlet code which sends the object
public void doGet(HttpServletRequest req, HttpServletResponse res) {
...
...
String str;
DataTransfer dataTransfer = new DataTransfer();
dataTransfer.setData(str);
ObjectOutputStream objoutputStream = new
ObjectOutputStream(res.getOutputStream());
objoutputStream.writeObject(dataTransfer);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Applet code which invokes the servlet
URL url = new URL("http://localhost:7001/testData");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
InputStream in = urlConnection.getInputStream();
ObjectInputStream objInputStream = new ObjectInputStream(in);
Object obj = objInputStream.readObject(); // This is the place where
the error is thrown
DataTransfer = (DataTransfer) obj;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~
-----Original Message-----
From: ceausu catalin [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 09, 2001 4:45 PM
To: [EMAIL PROTECTED]
Subject: Re: StreamCorruptedException: Header out of range 124
try to read all the stream bytes in a buffer and deserialize from the
buffer. (u can use a ByteArrayInputStream)
some servers send data chunks and java serialization does not handle
this situation(at least 1.3.1 i have installed)
Harinath D.P wrote:
> Ya ! It is a serialized one and it continues to throw this error
>
> -----Original Message-----
> From: herochinese [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 09, 2001 3:37 PM
> To: [EMAIL PROTECTED]
> Subject: Re: StreamCorruptedException: Header out of range 124
>
>
> Ensure ,your object was Serializable .
> ----- Original Message -----
> From: "Harinath D.P" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, November 09, 2001 5:01 PM
> Subject: StreamCorruptedException: Header out of range 124
>
>
> Hello all,
>
> I am trying to send an object from Servlet to Applet using
> ObjectOutputStream.
> In the applet it throws the following error.
>
> java.io.StreamCorruptedException: Header out of range 124
> at java/io/ObjectInputStream.readHeader
> at java/io/ObjectInputStream.readObject
> at com/ms/!!!Internal_Class_0.DefaultReadMethod
> at java/io/ObjectInputStream.invokeDefaultReadObject
> at java/io/ObjectInputStream.defaultReadObject
> at java/io/ObjectInputStream.readNewObject
> at java/io/ObjectInputStream.readObject
> at SampleApplet.hitServlet
> at SampleApplet.actionPerformed
> at java/awt/Button.processActionEvent
> at java/awt/Button.processEvent
> at java/awt/Component.dispatchEventImpl
> at java/awt/Component.dispatchEvent
> at java/awt/EventDispatchThread.run
>
>
> Any help would be appreciated.
>
> Thx
> harinath
>
>
________________________________________________________________________
> ___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
________________________________________________________________________
> ___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
________________________________________________________________________
___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
________________________________________________________________________
___
To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html