aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Error while downloading mpeg file from server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Error while downloading mpeg file from server" Watch "Error while downloading mpeg file from server" New topic
Author

Error while downloading mpeg file from server

ajay vasudevan
Greenhorn

Joined: Apr 23, 2005
Posts: 21
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
kapil munjal
Ranch Hand

Joined: May 11, 2004
Posts: 298
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


Kapil Munjal
SCJP 1.4, SCWCD 1.4
 
 
subject: Error while downloading mpeg file from server