• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error while downloading mpeg file from server

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
sos.write(bytes,0,data);


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.

rgds,

ajay vasudevan
scjp 1.4
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ajay,

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.

Thanks
Kapil
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic