You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Franck LANTRES <fr...@fr.renault-sport-f1.com> on 2001/07/27 08:54:41 UTC

PDF files under IE 5.0

Hi,

I know that my question is a little out-of-scope of this mailing-list : we have
problems with PDF files generating by servlets.
Our servlet generates PDF files using 'fop style sheets' and put the result in
the body of the HttpServletResponse. The problem is that the PDF file is
correctly viewed using Netscape (on Linux) but not using I.E. 5.0 (on WinNT) :
it seems that IE try on download this file from the server (same problem saving
the 'file' on local disk).

Here is the code :

String res = (String) resultString;
mimeType = mimeType + ";charset=ISO-8859-1";
sres.setContentType(mimeType);
sres.setContentLength(res.length());
sres.setBufferSize(res.length());
sres.setDateHeader("Expires", 0L);
sres.setHeader("Cache-Control", "no-cache");

PrintWriter out = sres.getWriter();
if( res != null)
	out.print(res);
out.flush();
out.close();
sres.flushBuffer();



Environment :
- Tomcat 4.0 Beta 5,
- Linux 2.4 (SuSE 7.1)
- JDK 1.3.1

Have you an idea ? Thanks a lot.

Franck.

Re: PDF files under IE 5.0

Posted by Franck LANTRES <fr...@fr.renault-sport-f1.com>.
I finally find the solution : just reset the buffer using the
HttpServlet.reset() method !!!!
Thank you IE :-(

Franck.

Franck LANTRES a écrit :
> 
> Hi,
> 
> I know that my question is a little out-of-scope of this mailing-list : we have
> problems with PDF files generating by servlets.
> Our servlet generates PDF files using 'fop style sheets' and put the result in
> the body of the HttpServletResponse. The problem is that the PDF file is
> correctly viewed using Netscape (on Linux) but not using I.E. 5.0 (on WinNT) :
> it seems that IE try on download this file from the server (same problem saving
> the 'file' on local disk).
> 
> Here is the code :
> 
> String res = (String) resultString;
> mimeType = mimeType + ";charset=ISO-8859-1";
> sres.setContentType(mimeType);
> sres.setContentLength(res.length());
> sres.setBufferSize(res.length());
> sres.setDateHeader("Expires", 0L);
> sres.setHeader("Cache-Control", "no-cache");
> 
> PrintWriter out = sres.getWriter();
> if( res != null)
>         out.print(res);
> out.flush();
> out.close();
> sres.flushBuffer();
> 
> Environment :
> - Tomcat 4.0 Beta 5,
> - Linux 2.4 (SuSE 7.1)
> - JDK 1.3.1
> 
> Have you an idea ? Thanks a lot.
> 
> Franck.

Re: PDF files under IE 5.0

Posted by Dmitri Colebatch <di...@bigpond.net.au>.
from memory ie tends to not pay full attention to mime-types.  For
example if you have a servlet which can be requested by .jpg and generates
an image with an binary stream mimetype IE seems to display it, even
though by rights it should save it (this is an old example from a year
ago).  So thinking along the same lines, if you made the servlet match
something.pdf then maybe it would work?

cheesr
dim

On Fri, 27 Jul 2001, Franck LANTRES wrote:

> Hi,
> 
> I know that my question is a little out-of-scope of this mailing-list : we have
> problems with PDF files generating by servlets.
> Our servlet generates PDF files using 'fop style sheets' and put the result in
> the body of the HttpServletResponse. The problem is that the PDF file is
> correctly viewed using Netscape (on Linux) but not using I.E. 5.0 (on WinNT) :
> it seems that IE try on download this file from the server (same problem saving
> the 'file' on local disk).
> 
> Here is the code :
> 
> String res = (String) resultString;
> mimeType = mimeType + ";charset=ISO-8859-1";
> sres.setContentType(mimeType);
> sres.setContentLength(res.length());
> sres.setBufferSize(res.length());
> sres.setDateHeader("Expires", 0L);
> sres.setHeader("Cache-Control", "no-cache");
> 
> PrintWriter out = sres.getWriter();
> if( res != null)
> 	out.print(res);
> out.flush();
> out.close();
> sres.flushBuffer();
> 
> 
> 
> Environment :
> - Tomcat 4.0 Beta 5,
> - Linux 2.4 (SuSE 7.1)
> - JDK 1.3.1
> 
> Have you an idea ? Thanks a lot.
> 
> Franck.
>