Hi,
    I have set a webapp like below:
    <Context path="/music" docBase="C:/My Music" debug="0"/>

    I have mp3 files in C:/My Music and I can reach the mp3 files like this:
    http://<ip>:8080/music/test.mp3
    and browser will play the song (with Win Media Player)

    is it posible that I use same webapps http://<ip>:8080/music/
    and play mp3 files in other directory?

    I have written a JSP that stream the mp3 files as below and it works,
    but is it possible that Tomcat can refer to the mp3 files in other
directory directly?
    or any other ways?


<%
 String filename = "C:\\my.mp3";

  File file = new File(filename);

  ReadableByteChannel rbc = Channels.newChannel(new FileInputStream(file));
  WritableByteChannel wbc = Channels.newChannel(response.getOutputStream());

   response.setContentType("audio/mpeg");
   response.setContentLength((int)file.length());
   response.setHeader("Content-Disposition", "attachment;
filename="+filename.substring(filename.lastIndexOf(File.separator)+1)+";");

   ByteBuffer bb = ByteBuffer.allocateDirect(1024);
   while (rbc.read(bb) != -1)
   {
    bb.flip();
    wbc.write(bb);
    bb.clear();
   }

   wbc.close();
   rbc.close();
%>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to