We get, in our opinion, a lot of failed download attempts and want to understand why.

We offer downloads via an email link (typical):


This is processed by Tomcat on Linux via a jsp file, with the following code:

response.addHeader( "Content-Disposition", "attachment; filename=" + fileTail );
response.addHeader( "Content-Type", "application/x-msdos-program" );
byte[] buf = new byte[8192];
int read;

try {
    java.io.FileInputStream input = new java.io.FileInputStream( filename );
    java.io.OutputStream o = response.getOutputStream();
    while( ( read = input.read( buf, 0, 8192 ) ) != -1 ){
        o.write( buf, 0, read );
} catch( Exception e ){
    util.fatalError( request.getRequestURI(), "Error sending file '" + filename + "' to client", e );
    throw e;

We get a lot of reported errors (about 50% error rate):


 Code Message: Error sending file '/home/sd/ShippingMasters/DMS/Domains/C/GCC3/Tools/TestCoverage/SD_C~GCC3_TestCoverage.1.6.12.exe' to client

 Stack Trace

 at org.apache.coyote.tomcat5.OutputBuffer.realWriteBytes(byte[], int, int) (Unknown Source)
 at org.apache.tomcat.util.buf.ByteChunk.append(byte[], int, int) (Unknown Source)
 at org.apache.coyote.tomcat5.OutputBuffer.writeBytes(byte[], int, int) (Unknown Source)
 at org.apache.coyote.tomcat5.OutputBuffer.write(byte[], int, int) (Unknown Source)
 at org.apache.coyote.tomcat5.CoyoteOutputStream.write(byte[], int, int) (Unknown Source)
 at org.apache.jsp.deliverEval.download_jsp._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source)
 at org.apache.jasper.runtime.HttpJspBase.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source)
 at javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source)
 at org.apache.jasper.servlet.JspServletWrapper.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, boolean) (Unknown Source)
 at org.apache.jasper.servlet.JspServlet.serviceJspFile(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String, java.lang.Throwable, boolean) (Unknown Source)
 at org.apache.jasper.servlet.JspServlet.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) (Unknown Source)
 at javax.servlet.http.HttpServlet.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) (Unknown Source)
 at org.apache.catalina.core.StandardWrapperValve.invoke(org.apache.catalina.Request, org.apache.catalina.Response, org.apache.catalina.ValveContext) (Unknown Source)

We don't understand why this rate should be so high. Is there any way to get more information about the cause of the error?

It is useful to know that these are pretty big documents, 3-50 megabytes. They reside on the Linux server so reading them is just a local disk read, and is unlikely to be a contributor to the problem. But sheer size might be an issue for the recipients browser?

Is this kind of error rate typical for downloads? My personal experience downloading other's documents suggests no; our internal attempts show this to be very reliable, but we're operating on our internal network for such experiments so we're missing the complexity of the intervening internet.

  • ClientAbortException ..? (easy to test, just try downloading a 50MB file and stop the download halfway through)
    – danlefree
    Dec 9, 2011 at 20:23
  • @danlefree: I believe if a client aborts, that we should see something like this, right. Is it really the case the 50% of users abort their downloads? Might it be the case that the abort the download if they figure out it is big, or it is taking longer than most tiny downloads take? I'm looking for technical causes (like you suggested), and psychology explanations (users have high abandon rate) from people with experience with this.
    – Ira Baxter
    Dec 9, 2011 at 20:38

1 Answer 1


Is there any way to get more information about the cause of the error?

Add the following to your logging: (I'm no Java guru but I believe that most of the variables you'll need are described in the org.apache.catalina.connector.Request documentation)

Full exception dump - e.toString() - the code sample provided does not differentiate between a client abort versus a failure to open a file so, unless logging occurs elsewhere when the exception is thrown, more information is needed to determine where things are going awry

Client IP, user agent, and HTTP referrer - do many of the requests share a common thread? (e.g. bot, source network, geographic location or distance, browser, linked from another site where download file size is not displayed, etc)

  • 1
    I have not had a chance to follow up on this, but you're the only person who provided any kind of hint. I bestow the points on thee... and thank you.
    – Ira Baxter
    Dec 15, 2011 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.