tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <mark.l...@boxstuff.com>
Subject Re: HTTP header for dynamic pdf and IE6
Date Sat, 05 Jun 2004 12:02:18 GMT
I've seen this before ;o)

Try appending .pdf to the actual request.

/myapp/pdfgen.do;iehack=.pdf

I've seen this used in teh xplanner project.

Mark

On 5 Jun 2004, at 11:52, Dean A. Hoover wrote:

> I have a java web application that allows
> an end-user in their browser to download
> a "file", which happens to be bytes stored
> in a database.
>
> In experimenting with how to do this, I have
> this snippet of code in my servlet:
>
>            AttachmentListItem attachment =
>             EmailSQL.getAttachmentListItem(connection, 3, 1);
>            response.setContentType(attachment.getContentType());
>            byte[] data =
>             EmailSQL.getAttachmentBytes(connection, 3, 1);
>            response.setContentLength(data.length);
>            response.setHeader("Content-Disposition",
>             "attachment; filename=\"" + attachment.getFileName() + 
> "\"");
>            ServletOutputStream out = response.getOutputStream();
>            out.write(data);
>            out.flush();
>            out.close();
>
> To test this out, I hit the link in my IE browser which brings up
> a dialog box allowing me to "Open" or "Save" the file. If I save
> the file, it does the right thing. If I press the open button, Acrobat
> Reader opens up and then errors out with an alert box:
> "There was an error opening the document. The file does not exist."
>
> I have a yahoo email account that I tried a test on. I sent an email
> message with the same pdf file attached to that account. I wanted to
> see if yahoo figured out how to make this work. They did! (but I can't
> figure out how to replicate)
>
> Their header looks like this:
> Date: Thu, 03 Jun 2004 15:37:58 GMT
> P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR
> ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi
> PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"
> Content-Disposition: attachment; filename=reference.pdf
> Connection: close
> Transfer-Encoding: chunked
> Content-Type: application/pdf; filename="foo.bar"
>
> .s4g--&v=1
>
> There is also some other stuff I am seeing just after the header: 
> .s4g-&v=1
> which looks something like a query string, but I'm not sure.
>
> My header looks like this:
> HTTP/1.1 200 OK
> Date: Thu, 03 Jun 2004 15:35:15 GMT
> Server: Apache/2.0.40 (Red Hat Linux) mod_perl/1.99_07-dev Perl/v5.8.0
> mod_jk/1.2.5 PHP/4.2.2 mod_python/3.0.1 Python/2.2.2 mod_ssl/2.0.40
> OpenSSL/0.9.7a
> Set-Cookie: JSESSIONID=DD3D0938B780EEBEBDC1B558CCBAD095; Path=/
> Pragma: No-cache
> Cache-Control: no-cache
> Expires: Thu, 01 Jan 1970 00:00:00 GMT
> Content-Disposition: attachment; filename="reference.pdf"
> Content-Length: 214982
> Keep-Alive: timeout=15, max=100
> Connection: Keep-Alive
> Content-Type: application/pdf;charset=UTF-8
>
>
> Does anyone know how to work around this problem? I suppose
> there are actually 2 parts to this:
> 1) What is the magic in the HTTP header that allows this to work?
> 2) How can one create such a header in java?
>
> Thanks.
> Dean Hoover
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>


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


Mime
View raw message