You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jerome Jacobsen <je...@gentootech.com> on 2001/12/03 16:57:30 UTC

RE: Servlet Download of large files broke Tomcat4.0.1

Sorry!  This was a bug in MY code, not Tomcat's!  There was a
change after all in my code between the version that works
and the one that doesn't.  It's fixed and working fine.

No problem with Tomcat.  No problem with com.oreilly.servlet
package.


-----Original Message-----
From: Jerome Jacobsen [mailto:jerome.jacobsen@gentootech.com]
Sent: Friday, November 30, 2001 2:58 PM
To: Tomcat Users List; jerome.jacobsen@gentootech.com
Subject: RE: Servlet Download of large files broke Tomcat4.0.1


After more testing I discovered that it is the UPLOAD that is broke.
It only uploads 31808 bytes out of my large files. 

On upload I insert the size of the file into a column.  I get this
from the File.length() of the File returned by
com.oreilly.servlet.MultipartRequest.getFile(String).  For my
example file this value is set correctly as 211134.  However, 
when I check the actual size of the content uploaded (via Oracle's
DBMS_LOB.GET_LENGTH function) it says only 31808!

Now again, these big files work fine under Tomcat 3.2.

Anyone experiencing this??


-----Original Message-----
From: Jerome Jacobsen [mailto:jerome.jacobsen@gentootech.com]
Sent: Friday, November 30, 2001 1:57 PM
To: Tomcat User's Group
Subject: Servlet Download of large files broke Tomcat4.0.1


Hi,

I've got a servlet for uploading and downloading 
files using com.oreilly.servlet package.  It worked 
fine under Tomcat 3.2 for large files (> 2MB). 
Under Tomcat 4.0.1, with everything else the same, 
it won't download large files.  

For example, downloading a 3MB PDF file via 
Netscape spawns Acrobat which says: 

"There was an error opening this document.  Could not repair file."

They seem to be uploaded OK.  They go into an 
Oracle database table which reveals the file size.
The file size for these docs are the same as those
in the working Tomcat 3.2 case.

The logs don't indicate anything exceptional.

Did something change in Tomcat 4 wrt. downloading
large files?

Environment:
Tomcat 4.0.1
Red Hat Linux 6.2
Sun JDK 1.3.1 (using classic JVM)

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


RE: Tomcat 5 and returning PDF in response outputstream

Posted by Jerome Jacobsen <je...@gentootech.com>.
I've been able to generate PDF in the response output stream in Tomcat 5.
I used the example from this O'Reilly OnJava article:

http://www.onjava.com/pub/a/onjava/2003/06/18/dynamic_files.html

The code of interest is shown below:

<code>
resp.setHeader("Cache-Control", "max-age=30");
resp.setContentType("application/pdf");

StringBuffer sbContentDispValue = new StringBuffer();
sbContentDispValue.append("inline");
sbContentDispValue.append("; filename=");
sbContentDispValue.append(sbFilename);

resp.setHeader(
	"Content-disposition",
	sbContentDispValue.toString());

resp.setContentLength(baosPDF.size());
ServletOutputStream sos;
sos = resp.getOutputStream();

baosPDF.writeTo(sos);
sos.flush();
</code>

I'm using Tomcat 5.0.28 on Windows 2000 with JDK 1.4.1_02.

Give this example a try.

-Jerome


> From:       "Jeremy Nix" <Jeremy.Nix () sfsltd ! com>
> Date:       2004-10-01 16:50:30
> Message-ID: <7503E16AAE4DB3498884AB2DC4B779D501A51AE2 () fernhill ! sfsltd
! com>
>
> Has anyone else had trouble rendering PDF's (in Internet Explorer) when
> sending the pdf directly into the response outputstream and rendering in
> Internet Explorer?  I realize there are a lot of factors at work here,
> but I find that my configuration works fine when I switch to Tomcat
> 4.1.30.  I'm setting the content type and content length on the
> response.  The code I use is below:
>
> 	pdf = generatePDF();
> 	response.resetBuffer();
> 	response.setHeader("Cache-Control", "max-age=30");
> 	response.setHeader("Content-Disposition", "inline;
> filename=generated.pdf; size=" + pdf.getBytes().length);
> 	response.setContentType("application/pdf");
> 	response.setContentLength(pdf.getBytes().length);
> 	response.getOutputStream().write(pdf.getBytes());
> 	response.flushBuffer();
>
> If I access my url with Netscape, the pdf displays correctly.  If I save
> it out to the filesystem (on server side), pdf displays correctly. It's
> just something with the configuration of Tomcat 5 and Internet Explorer
> that is not working correctly.  The same code posted above works for
> both Netscape and IE when run under Tomcat 4.1.30.
>
> Has anyone had similar problems?
>
>
> _________________________________
> Jeremy Nix
> Senior Application Developer
> Southwest Financial Services, LTD.
> (513) 621-6699 x1158
> www.sfsltd.com


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org