You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gia Thornton <fo...@yahoo.com> on 2005/03/02 23:26:15 UTC

Write file to browser tomcat error

Hi,
I am using the code below in a jsp to write a jar file to the browser so that user can download it. However, after the user hit download to save the file, the tomcat server display an error caused by flushing the buffer. Does anyone know why it happens? Thank you for your help

-------------------------------------------------------
try{
String disHeader = "Attachment;Filename=\"" + jarName +"\"";
response.setHeader("Content-Disposition", disHeader);
response.setContentType("APPLICATION/OCTET-STREAM"); 

FileInputStream fileInputStream = new FileInputStream(jarFile);

int i;
while ((i=fileInputStream.read())!=-1)
{
out.write(i);
}
fileInputStream.close();
out.close(); //This line gives the problem
}

catch(Exception e) // file IO errors
{
System.out.println("######### file error");
e.printStackTrace();
}
--------------------------------

error:

org.apache.jasper.runtime.PageContext: Internal error flushing the buffer in release() 

		
---------------------------------
Celebrate Yahoo!'s 10th Birthday! 
 Yahoo! Netrospective: 100 Moments of the Web