• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error while downloading mpeg file from server  RSS feed

Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An exception occurs while i try to view a mpeg file by using servlets.the mpeg file resides on the server.i used res.setContentType("video/mpeg"),got an Inputstream from ServletContext, got an outputstream and wrote the bytes.

but got the Exception while downloading the file at the client.
ClientAbortException;java.net.SocketException,Connection reset by peer.
socket write exception at line .....

the line is

i changed the contentType as setContentType("video/quicktime"),but the file couldn't be recognized at the client.it shows blank at filetype so the user has to choose from the type of program to open the file.

i want the foll. scenario.

when the page is submitted ,the file gets downloaded automatically and can be view in the browser itself.(or the concerned the media player )

please do help me with this dilemma.


ajay vasudevan
scjp 1.4
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have not worked on this mpeg file format. But the way to do it is that...by changing the format of the servlet content type...whenever that servlet is called, it will return a file with that format. But if you want to play in the browser, then you need to call the plugin for that i.e. you need to make an html page in which there will be a plugin for running that file and it will be displayed in the browser.

You can do it without using streams, that will be an easier method.

when a form is submitted then call the url with the name of mpeg file.(e.g. http://www.jsp.com/mpeg/my_film.mpeg

when you will redirect to this file then file will be transferred to the client. And he will have the option to open or save the file.

Please someone who has worked on this, verify these methods.

Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!