File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes opening a  video file in a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "opening a  video file in a browser" Watch "opening a  video file in a browser" New topic

opening a video file in a browser

nalini peddareddy

Joined: Jul 18, 2005
Posts: 16
I have a problem opening a video file in a browser through an application.

Techhologies used are servlets and templates

Here is the flow for ur understanding.

I have a link in a template clicking on which calls a javascript(openWindow)taking the url as parameter)Before opening the file the following process takes place.

Reads the file from the database and stores it in a filestore(some folder in server)

//Write the file from BLOB (taking the file data from database)

and then stores it in filestore by taking fileID and filepath.fileIdentifier is the filename.

File oFile = new File(filePath + "/" + fileIdentifier);
out = new BufferedOutputStream(new FileOutputStream(oFile),

//create byte buffer and start reading the file
byte[] b = new byte[bufferSize];
int count =, 0, bufferSize);
logger.debug("Writing file now");

while (count != -1) {
out.write(b, 0, count);
count =, 0, (int) bufferSize);
} // end count!=-1

out = null;
in = null;

After all this process it opens a new window displaying the content of the file

This is all working fine for text files, docs and images but is not the case for opening an audio and video file. For video file ,it opens a new window displaying junk text.

Here is the javascript called on clicking the link in the template.

function openFileinWindow(url, width, menubar){
// has not yet been defined,'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');
//has been defined
// still open
},'new1','menubar=' + menubar + ',toolbar=yes,scrollbars=yes,width=' + width + ',height=450');

Could you please help me out in this topic?

Thank you
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
I am not sure, but worth checking.
From command prompt type the "assoc". This command is intended to Displays or modifies file extension associations.
Look for the your audio and video file associations. If not present use the same to associate to audio or video players. same command can be use to associate. Use command "help assoc" to get more details about the assoc command.


Sharing is learning
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Arun is talking about desktop configuration, which certainly matters, but unless your client machine has never been used to view video at all (seems unlikely) I doubt that is the problem. The first thing that occurs to me is that that you haven't shown us any code which sets the content-type for the download -- are you sure you're setting it correctly?

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: opening a video file in a browser
It's not a secret anymore!