You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Neil Carusetta <nc...@computer-guidance.com> on 2002/11/14 16:46:41 UTC

Opening PDF file: Problem and Solution

Has anyone had any difficulties with opening a PDF file byte stream in a
browser using sub-apps?  We got it working but are still unclear as to
exactly the reason.

Up front I'll mention that we are using sub-applications.

We had an action which places a PDF file in the form of a byte[] out on the
ServletOutputStream.  For some reason the file would not display in the
Acrobat plugin.  The IE dialog to open or save the file would instead
appear.  At this point we were able to save the PDF to the client machine,
but still remained with the problem of not being able to view the PDF in IE.
Now trying this same thing using just a default app worked fine. But we had
to make it work using a sub-app. 

Now comes the confusing part.  Streaming out JPEG and Word files worked just
fine in our sub-app.  Of course, for all three files we are setting the
appropriate contentType on the response. 

We then thought that there might be a problem with the sub-app's
configuration.  We noticed that in the struts config file, through the
controller element, we were setting the contentType to "text/html".  For
some reason, removing the contentType allowed the stream to be opened in
Acrobat.

It seems that the contentType setting in the sub-app was overriding that for
"application/pdf" but not for "image/jpeg" or "application/msword".  Does
anyone know why this would be the case?

Best of luck,

Neil Carusetta
CGC
Scottsdale, AZ

 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>