This is what tcptrace tells me is being sent back to the browser

HTTP/1.1 200 OK
Pragma: No-cache
Cache-Control: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-disposition: attachment; filename=N77-NTSP-E-70-0203.pdf
Content-Type: application/pdf
Content-Length: 443928
Date: Tue, 11 May 2004 19:29:37 GMT
Server: Apache-Coyote/1.1

If I remove the Content-disposition then the PDF opens in the browser ok,
but that is not what I want.
Secondly Mozilla still asks for the file twice and gets it, but only
displays one of them.


-----Original Message-----
From: Christoph Meier [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 11, 2004 12:28 PM
To: Tomcat Users List
Subject: Re: Streaming pdf document fails


As far as i remeber, IE wants to know the content-length to show a PDF. =>
put the appopriate content-length into your Response-Header, ensure 
to have set the right content-type and i would expect that the 
PDF-stream should work then for IE, too.

_christoph

>I have a problem that just came up.  I have PDF documents located out 
>side of my webapps directory. When the user wants one they go to my 
>servlet which streams it back. This use to work just fine, but now is 
>broke.
> 
>In IE I get Error opening document on TC4.1.30 and unable to open this 
>Internet site in TC 5.0.19
> 
>Mozilla 1.6 does not have a problem opening the file.
> 
>What is odd is that Mozilla seems to request the servlet twice from one 
>click, the first tends to throw this
>ClientAbortException:  java.net.SocketException: Software caused 
>connection
>abort: socket write error
>        at
>org.apache.coyote.tomcat4.OutputBuffer.realWriteBytes(OutputBuffer.java:410
)
>        at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:332)
>        at
>org.apache.coyote.tomcat4.OutputBuffer.writeBytes(OutputBuffer.java:438)
>        at
>org.apache.coyote.tomcat4.OutputBuffer.write(OutputBuffer.java:425)
>        at
>org.apache.coyote.tomcat4.CoyoteOutputStream.write(CoyoteOutputStream.java:
1
>08)
>        at GetPDFDoc.outputFile(GetPDFDoc.java:128)
>        at GetPDFDoc.processRequest(GetPDFDoc.java:86)
>        at GetPDFDoc.doGet(GetPDFDoc.java:147)
> 
>Is there anything wrong with what I am doing?
>      response.setContentType("application/pdf");
>      response.setDateHeader("Expires", 0);
>// open pdf outside of browser
>      response.addHeader("Content-disposition", "attachment; filename=" 
>+ ntspNo + ".pdf");
>      response.setContentLength((int)f.length());
>      java.io.OutputStream out = response.getOutputStream(); // f is 
>the pdf on the file system and it does exist
>      java.io.FileInputStream in = new java.io.FileInputStream(f);
>      int size = 0;
>      byte[] buffer = new byte[8192];
>      while( (size = in.read(buffer, 0, buffer.length)) != -1)
>      {
>        out.write(buffer, 0, size);
>      }
>      in.close();
>      out.close();
> 
>Thanks
>
>  
>



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

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

Reply via email to