Hello

I am trying to do some pretty simple stuff sending some large files
from a servlet.

The response is just a standard HttpServletResponse. The code looks
something like this:

---------------
response.setHeader(HTTP_CONTENT_DISPOSITION, "attachment; filename=" +
fileName);
response.setContentType(contentType);
response.setContentLength((int) resourceFile.length());

InputStream is = new FileInputStream(resourceFile);
OutputStream os = response.getOutputStream();
byte[] buf = new byte[BUFFER_SIZE];
int nbytes;
while ((nbytes = is.read(buf)) != -1) {
     os.write(buf, 0, nbytes);
}
---------------

The exception thrown is as follows:

------------
java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:2786)
        at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
        at 
java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:161)
        at 
java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:118)
        at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
        at 
net.sf.ehcache.constructs.web.filter.FilterServletOutputStream.write(FilterServletOutputStream.java:58)
        at 
com.opensymphony.module.sitemesh.filter.RoutableServletOutputStream.write(RoutableServletOutputStream.java:118)
        at 
com.myapp.controllers.ResourceDownloadController.sendResource(ResourceDownloadController.java:127)
------------

I confess I dont really understand why it would be complaining here
since I am just writing streams. Does anyone have any ideas?

Also why is the stream being compressed? Any way to switch that off?

Thanks

Jonathan

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

Reply via email to