I'm a 'tard.

you should call the setContentType() and whatever the ...size() method is on the response object, rather than writing that to the output stream. *THEN* write the bytes out.


From: "Adam Levine" <[EMAIL PROTECTED]> Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: [EMAIL PROTECTED] Subject: RE: Using bean:write to display/stream PDF content -- please help. Date: Wed, 23 Jul 2003 10:03:48 -0500

I think you're missing the bigger concept. A PDF is the same as a JPG - it's a media file that differs from just the plain text sent in an html page.

You can't just stream a PDF in the middle of HTML. You have to associate it with a content type, and the browser has to make a request for it, just like it does for images. One HTML page with 2 images == 3 requests to the server: 1 for the text, 1 for each image. Browsers (generally) won't make a request for a PDF embedded in the page, as there is not related tag (like the img= for gif/jpg).
So, if your user gets to your stored PDF by clicking a link, your rendering JSP page might look like this:


<myTag:showPdf pdfid="123"/>

your tag would then:
-    output the Content-Type and (ideally) filesize to the datastream
-    then write out the bytes of the PDF file to the datastream
-    end the tag

the browser will handle everything else

out.println("Content-Type=.......

byte[] pdf = loadPdf(123);

// write the bytes to out in whichever manner is most efficient




From: [EMAIL PROTECTED] Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Subject: RE: Using bean:write to display/stream PDF content -- please help. Date: Wed, 23 Jul 2003 10:55:32 -0400



And then what? I can easily access it from the form bean field and from
the session. There's no problem here. The question is how to stream it to
the client. Please see my previous email.



Please respond to "Struts Users Mailing List"
<[EMAIL PROTECTED]>
To:     "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
cc:

Subject:        RE: Using bean:write to display/stream PDF content --
please help.




JSP is the same as Servlet. Put your pdf content in the session scope, you can get it on your jsp page through session.getAttribute("pdfContent");


-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: July 22, 2003 7:18 PM To: [EMAIL PROTECTED] Subject: Using bean:write to display/stream PDF content -- please help.

[SNIP]

I know the best way to do it is to have a servlet. But I need to do it in
a JSP because of certain limitations of my application. Please help.

Thanks.




This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.


--------------------------------------------------------------------- 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]







This transmission may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you.


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

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963



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

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



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



Reply via email to