hello,
your solution works fine! thanks :)
by the way, do you have any idea what could the the problem using the
subclass?
Héctor López wrote:
>
> I'll watch out for 2 things:
> - The byte array is available when the response.write() occurs
> (transactions
> and DB access)
> - The resolution subclass is unnecessary in this case
>
> Better replace that code with this one:
>
> public Resolution showContent() {
> final byte[] is =
> this.contractContentService.get(this.getIdContractContent()).getByteContent(
> );
> StreamingResolution res = new StreamingResolution("application/pdf", new
> ByteArrayInputStream(is)).setFilename("contract.pdf");
> return res;
> }
>
> Hope it helps!
>
>
>
> -----Mensaje original-----
> De: Rochat Aurelia [mailto:[email protected]]
> Enviado el: martes, 14 de abril de 2009 9:05
> Para: [email protected]
> Asunto: [Stripes-users] problem downloadin a pdf file using Stripes
>
>
> hello,
>
> I have a jsp with a form allowing to upload a file in pdf format; the file
> is then stored in an Oracle database as a BLOB object. This part works
> fine
> : if I retrieve the file directly from the database everything is ok.
>
> But I have another jsp that allows to download the same file, and this
> doesn't work properly. When I save the file and then open it, it appears
> as
> blank. The size of the downloaded file is smaller than the original one
> (10.1 Ko instead of 10.7 Ko).
> I tried with another file, which size is 11.2 Ko, and when I download it,
> the resulting file is 10.6 Ko.
>
> Here is the function called to download the file :
>
> public Resolution showContent() {
> final byte[] is =
> this.contractContentService.get(this.getIdContractContent()).getByteContent(
> );
> StreamingResolution res = new
> StreamingResolution("application/pdf") {
> @Override
> protected void
> stream(javax.servlet.http.HttpServletResponse response) throws Exception {
> String value = new String(is);
> response.getWriter().write(value);
> }
> }.setFilename("contract.pdf");
> res.setCharacterEncoding(null);
> return res;
> }
>
> contractContentService is a service that retrieves the BLOB object from
> the
> database, and getByteContent() returns the content of the file as a byte
> array.
> This function works perfectly if I retrieve a txt file from the database.
>
> Anyone has an idea the problem might be for a pdf file?
>
> Thanks
> ----------------------------------------------------------------------------
> --
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
--
View this message in context:
http://www.nabble.com/problem-downloadin-a-pdf-file-using-Stripes-tp23034251p23037716.html
Sent from the stripes-users mailing list archive at Nabble.com.
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users