Don't use a form property and don't set the content type in the action. Stuff
the data in a request attribute instead and forward to a JSP with something like:

<%@ page contentType="application/pdf" %>
<%
ServletOutputStream oStream = response.getOutputStream();
byte[] pdfData = (byte[])request.getAttribute("pdfData");
oStream.write(pdfData);
%>

Quoting [EMAIL PROTECTED]:

> 
> 
> That is what I need. I mentioned the word "gurus" in my question :)
> 
> 
> 
> 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.
> 
> 
> 
> Bean write may not be converting the property correctly, it's just
> tostring'ing it, which is why you see the address of the object. You need
> something that will stuff the binary form of the PDF into the response
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 23, 2003 11:09 AM
> To: Struts Users Mailing List
> Subject: RE: Using bean:write to display/stream PDF content -- please
> help.
> 
> 
> 
> 
> Did you try this code yourself? I am telling you that this is exactly what
> I have done and it does not work. I have a form bean that has a byte array
> attribute that I populate in the action and then set the content type and
> use bean:write on that attribute in the JSP and it just displays the
> address of the byte array on the screen instead of loading PDF. I don't
> think the JSP and bean:write work correctly with the byte array fields.
> The question was a tricky one. If it was that simple, I would not have
> sent so many emails. Any other ideas?
> 
> 
> 
> Please respond to "Struts Users Mailing List"
> <[EMAIL PROTECTED]>
> To:     [EMAIL PROTECTED]
> cc:
> 
> Subject:        RE: Using bean:write to display/stream PDF content --
> please help.
> 
> 
> 
> 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.

-- 
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

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

Reply via email to