//This generates a 23kb file...that doesnt display data in acrobat, 19blank pages BufferedOutputStream bos = new BufferedOutputStream(resp.getOutputStream()); bos.write(bytes,0,bytes.length); bos.flush(); bos.close();
//This generates a 23kb file...that displays the correct data in acrobat, 19 pages with data BufferedOutputStream bosFile = new BufferedOutputStream(new FileOutputStream("c:\\test3.pdf")); bosFile.write(bytes,0,bytes.length); bosFile.flush(); bosFile.close();
The thing that bugs me is that the files are different when i view them thought wordpad. The one gets send to the browser, the other to my c drive. But as you can see, they are produced with the same byte.
I don't know what is glassfish and neither I know what is 8.x.
What I think is happening is resp.getOutputStream() is somewhere using byte for its implementation because of which some characters are mixed up. It should be chars above 127. Try using an ASCII file (ant .txt/.rtf file) and see whether it opens up. You can also try using a hex editior/comparator to see which chars are getting mixed up.
Didn't read the whole post clearly. Using a byte array might also be a problem. But I have no clue why it is working in one and not in the other case. [ November 14, 2006: Message edited by: Anupam Sinha ]
posted 13 years ago
Thanks for all the reply`s.
Rahul: I`ve copied your code...still nothing.
Anupam Sinha: Glassfish is the latest version of the Sun Java Application Server. And i must agree...that is sort of what i think is happening to...the files (one on harddrive and one thought browser) have a slight difference on certain characters...it seems like the encoding is screwing this up.
if i do a request.getRequestDispatcher("/reports/generated/myfile.pdf") it also displays the file as blank...but going strait to the location on the machine the file works....so it really looks like the way the file is being streamed to the browser.
Any other ideas?
SCJP, SCJD, SCWCD, SCBCD (JEE)
posted 13 years ago
One more thing I would certainly like you to try ;-)