aspose file tools
The moose likes JSP and the fly likes Showing pdf files in jsp giving error Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Showing pdf files in jsp giving error

Raj Puri
Ranch Hand

Joined: Apr 24, 2003
Posts: 189
I am usinhg JSP to show pdf or word files in IE browser. The files are stored as Blob in Oracle database. The following code should show the file when I run JSP, but it shows all garbage along with text of pdf file. I tried the same with another file that is stored as word after changing content type to application/windoc that also does not work. What am I doing wrong here? I did verify that file was right as I laoded them using Oracle utility.


-------->

BLOB b = ((OracleResultSet)rset).getBLOB (1);

byte[] ba = b.getBytes(1, (int)b.length());
response.setContentType("application/pdf");

OutputStream os = response.getOutputStream();
os.write(ba);
os.close();
b.close();
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

This is why you should never use a JSP to do a Servlets job. And please don't ask what is essentailly the same question more than once. Please continue any discussion in the original topic.
[ May 20, 2005: Message edited by: Bear Bibeault ]

[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Showing pdf files in jsp giving error
 
Similar Threads
Oracle text search
need to read the blob and convert it into a file
PDF, BLOB and STRUTS
WebLogic Server - Problem encoding file MS Word in jsp
Display pdf file contents through jsp