Bookmark Topic Watch Topic
  • New Topic

Showing pdf files in jsp giving error

 
Raj Puri
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!