This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

opening a video file in a browser

nalini peddareddy
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Ernest Friedman-Hill
author and iconoclast
Posts: 24208
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic