Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

downloading pdf file from server to client makes it empty

843842Mar 13 2009 — edited Mar 14 2009
Hello All,
I have an application which allows users to download the pdf files.
when a user clicks the link the pdf file should get downloaded from server to client side.
right now it gets downloaded but the file is empty when I open it.
file size is a bit more than the actual .but contents are not visible/may be corrupt.

what I am doing is this


reading the original file on server in buffered reader.
creating an output stream using httpservlet response object.
setting the headers for pdf correctly in httpservlet response object.
then writing the data line by line by reading the buffered reader and writing it out to outputstream.

I am flushing the outputstream after write and also closing it properly.but dont know why its not working
other files like excel, csv , txt files get downloaded correctly using same code.only pdf gives error.
Ajax is used as UI technology. could this be issue on client side receiving something garbage or wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2009
Added on Mar 13 2009
6 comments
899 views