Problem with writing bytes with OutputStream

Hi guys

I'm reading an audio file from the database and writing it to the response object via a servlet and playing it in the browser using the embed tag.

It works well with Internet Explorer but with Mozilla - i get the following error.

ClientAbortException: java.net.SocketException: Connection reset by peer: socket write Error

And the file does not play.

This is how my java code is:

Blob b = rs.getBlob("BINARYFILE");

byte[] ba = b.getBytes(1, (int)b.length());

OutputStream os = response.getOutputStream();

response.setContentType("application/x-mplayer2" );

os.write(ba);

os.close();

I'm sure nothing is wrong in the code as it works well in Internet Explorer. But in Mozilla it throws the above error.

This is how i'm using the Embed tag in JSP : Connection is the Servlet that writes the binary data to the response

<EMBED SRC="http://localhost/music/Connection?id=99837425"type="application/x-mplayer2" [code]

autostart="true" >

</EMBED>

[/code]

Any help would be appreciated

thanks

gublooo

[1311 byte] By [gubloooa] at [2007-10-2 15:19:34]
# 1

And one more thing.

I have all the plugins installed to play the file in mozilla.

Cos if I use the Embed tag and specify the location of the audio file on disk - it plays it well in mozilla also. Like

<EMBED src= "c:\music.mp3"

type="application/x-mplayer2"

>

This works in mozilla and the file is played.

So i know there is some problem in the code or something. Cos the above error does not appear when i use Internet explorer - only in mozilla

Thanks

Gublooo

gubloooa at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

I noticed one more thing today.

With Mozilla when I call the JSP page - it invokes the Servlet twice. Like its making 2 calls to the servlet or something.

I dont see that behavior with Internet Explorer.

I've searched on the net for that error and everyone seems to say just ignore it since it happens when the client aborts the connection by pressing the STOP button or closing the browser. I'm not doing either.

I have no idea what is going on. If i find something new - I will keep you all updated.

thanks

gubloooa at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Well thanks guys - I just solved the problem :)
gubloooa at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
How have you been solved the problem?Tanks in advance!!
darngara at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Can you please update me on how you solved your problem coz am facing similar kind of stuff... Thanks in advance.
sriHarrya at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6
Could you post the solution please. I have been surfing the net for a solution to this, but you seem to be the only one that has cracked this !Pass the cheer....
happycampera at 2007-7-13 14:26:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...