• Post Reply 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Open PDF or word doc or text file from byte array data using JSF.

Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have byte array data available. Along with byte array, I do get the property information like what the bytearray stands for like PDF or Word or JPG etc. How can I display or open this data in the browser accordingly. An action in JSF is causing me to read the bytearray data. Now I want to navigate to a new page to display or open the byte array content.
Saloon Keeper
Posts: 27919
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Internet Explorer is legally restricted against opening PDF's and Office documents in the IE browser Window due to a patent on that technology. The best you can do is set up for the document to be opened in its application (Adobe Reader or Office).

To do that, you need a "pure" data stream, not an HTML data stream, so JSF is not a good choice to output this data. It's better to have a servlet do this output.

To get the proper application to open output data, you need to let the browser know what type of data it is, and you do that by setting the MIME type for the output data before you start outputting the data itself. Normal web pages have a MIME type of "text/html". There are special MIME types for PDF's and Office documents, and although I don't remember their exact values, they tend to begin with "x-vnd/".
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic