Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Showing pdf files in jsp giving error

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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();
 
Sheriff
Posts: 67695
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
    Bookmark Topic Watch Topic
  • New Topic