aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not able to write Binary Data" Watch "Not able to write Binary Data" New topic
Author

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
thanks
gublooo
[ April 23, 2006: Message edited by: Bear Bibeault ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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: java.net.SocketException: Connection reset by peer: socke
t write error
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:366)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:328)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:392)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:381)
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:76)
at java.io.BufferedOutputStream.write(Unknown Source)
at com.world.servlet.MusicConnectionServlet.streamBinaryData1(MusicConnectionServlet.java:127)
at com.world.servlet.MusicConnectionServlet.doGet(MusicConnectionServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
 
Don't get me started about those stupid light bulbs.
 
subject: Not able to write Binary Data