I have a very strange problem that I hope someone can help with. I have a servlet that streams (using ServletOutputStream) various web and media files (mp3, mpegs, etc..). The media files are not in the web dir. This servlet is designed to restrict access to the media files. For most files this works, but for mp3s, it is not working properly. It's stream most mp3 fine, but about 20% of the time, it will have a 50 sec delay. There should be no delay (I'm on the same network). Other files types (asf, mwf, mpegs, etc..) seem to work fine. Below is the servlet code. I'm at a loss. Please help. :) Oh, a few notes. 1) I'm using JBoss-2.4.4 with embeded Tomcat. 2) This code work when I were using weblogic and seem to appear when we ported to jboss. 3) we are using media player to play the media files.
-chris ======= public void service(HttpServletRequest request, HttpServletResponse response) { .... code here to check if the user has permission to get hiddne media file and get the files path...... if (!physicalFile.exists()) { element_error("Error: Cannot find physical file for requested element.",response); return; } fileSize = physicalFile.length(); mimeType = MimeType.getMimeType(physicalFile.getPath()); if (mimeType.equals("application/octet-stream")) { response.setHeader("Content-Disposition", "filename=" + physicalFile.getName()); } FileInputStream in = null; BufferedInputStream input = null; ServletOutputStream output = null; try { in = new FileInputStream(physicalFile.getPath()); input = new BufferedInputStream(in, BUFFER_SIZE); output = response.getOutputStream(); } catch (Exception e) { element_error("Error getting streams",response); element_error(e.toString(),response); return; } //response.setHeader("X-Testing", "this is a test change"); response.setHeader("Keep-Alive", "timeout=10, max=20"); response.setHeader("Connection", "Close"); response.setHeader("Accept-Ranges","bytes"); response.setHeader("Content-Length",String.valueOf(physicalFile.length())); response.setHeader("Content-Type", mimeType); System.out.println("sending file:" + physicalFile.getPath()); System.out.println("file type:" + mimeType); try { while ((bytesRead = input.read(buffer)) != -1) { readCount++; System.out.println("before write:"); output.write(buffer, 0, bytesRead); System.out.println("after write:"); System.out.println(readCount); System.out.println(bytesRead); } } catch (Exception e) { //e.printStackTrace(new PrintWriter(System.out)); System.out.println("caught exception during write: " + e.toString()); System.out.println("reads=" + readCount + " bytesRead=" + readCount * BUFFER_SIZE); System.out.println("mimeType=" + mimeType + " file=" + physicalFile.getPath()); return; } //input.close(); //in.close(); try { output.flush(); output.close(); System.out.println("ending.."); //response.flushBuffer(); } catch (IOException e) { System.out.println("error closing input stream - " + e.toString()); } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>