Sheldon,

it is important for IE to the the length of the stream. 
response.setContentLength(byteArray.length);

That was the solution in our case.

Regards,
Bernhard


-----Ursprüngliche Nachricht-----
Von: Jarnot Voytek Contr AU HQ/SC
Gesendet: Montag, 3. Februar 2003 19:55
An: 'Struts Users Mailing List'
Betreff: RE: Streaming PDF file problem


I was having an IE + PDF problem as well; it seems that IE refuses to
display a streamed PDF when using method=post - used get and everything
started working...

I didn't like this solution, so we ended up saving the PDFs to disk
(sessionid.pdf) and redirecting to them.  We've got a session listener that
deletes the sessionid.pdf files when the session is destroyed.

--
Voytek Jarnot
Quidquid latine dictum sit, altum viditur.


> -----Original Message-----
> From: [EMAIL PROTECTED]
> Sent: Monday, February 03, 2003 12:49 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Streaming PDF file problem
> 
> 
> BTW, the code for streaming a servlet works perfectly as a stand alone
> servlet, but fails for IE in the struts framework.
> 
> Sheldon
> 
> >  -----Original Message-----
> > From:       Chan, Sheldon  
> > Sent:       Monday, February 03, 2003 9:36 AM
> > To: '[EMAIL PROTECTED]'
> > Subject:    Streaming PDF file problem
> > 
> > Hi all,
> > 
> > I'm trying to stream a PDF from a Struts action by writing 
> an array of
> > bytes to the OutputStream of HttpServletResponse.  It works great in
> > Mozilla, however it fails on IE.  When I attempt to execute 
> the action, IE
> > brings up its "Save or Open" dialogue box with the request 
> Url as the file
> > it's trying to save.  When I click on "Save", it gives me an error
> > dialogue of "Internet Explorer cannot download... ".  Any ideas?
> > 
> > Thanks in advance for any help.
> > 
> > Sheldon
> > 
> > 
> > Here's the psuedo-code.
> > 
> > OutputStream outputstream = null;
> > 
> > try {
> >     byte[] responseBytes = getBody().getBytes(ENCODING);
> > 
> >     response.setContentType("application/pdf");
> >     response.setContentLength(responseBytes.length);
> >     response.setHeader("Content-Disposition",  
> >                                   "attachment; 
> filename=myfile.pdf");
> >     response.setHeader("Pragma", "no cache");
> >     response.setHeader("Cache-Control", "no-cache");
> > 
> >     outputStream = response.getOutputStream();
> >     
> >     outputStream.write(responseBytes, 0, responseBytes.length);
> > } catch (Exception e) {
> >    // do something
> > }  finally {
> >     outputStream.close();
> > }
> > 
> 
> ---------------------------------------------------------------------
> 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]

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

Reply via email to