File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Not able to write Binary Data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not able to write Binary Data" Watch "Not able to write Binary Data" New topic

Not able to write Binary Data

Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45
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.

And the file does not play.

This is how my java code is:

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

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

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

Any help would be appreciated
[ April 23, 2006: Message edited by: Bear Bibeault ]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

You need to set the Content-length header, for one thing.

[Jess in Action][AskingGoodQuestions]
Gilbert johnson
Ranch Hand

Joined: Jul 10, 2005
Posts: 45
Thanks for your reply.

Yes I am already setting the content length. Is there any other header that I need to set for Mozilla. This is the entire stack trace that I see when I access the site on Mozilla but not on IE.

ClientAbortException: Connection reset by peer: socke
t write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(
at org.apache.tomcat.util.buf.ByteChunk.append(
at org.apache.catalina.connector.OutputBuffer.writeBytes(
at org.apache.catalina.connector.OutputBuffer.write(
at org.apache.catalina.connector.CoyoteOutputStream.write(
at Source)
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
I agree. Here's the link:
subject: Not able to write Binary Data
jQuery in Action, 3rd edition