This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Struts and the fly likes PDF display in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "PDF display in JSP" Watch "PDF display in JSP" New topic

PDF display in JSP

Nivan scorp

Joined: Dec 06, 2004
Posts: 23
I need to display a pdf document within an iframe in a JSP page.
The pdf is in the form of byte array.

Any clue on how this can be achieved?

Horatio Westock
Ranch Hand

Joined: Feb 23, 2005
Posts: 221
You could create a servlet to stream the blob data.

e.g. http://yoursite/fileservlet?id=5

Then have that as the source of your iframe. Basically the servlet implementation would simply query for the blob then direct the stream from the backend to the servlet output stream. If you search the web for "jsp image blob" or something similar, you should be able to find some sample code. Remember also to consider things like content-type and cache headers.

Alternatively I think there are probably some taglibs to help with this, but personally I prefer option 1.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: PDF display in JSP
Similar Threads
Jsp to pdf
preview of pdf files in browsers.
Opening pdf file using jsp
How Display image in a JSP that retrieved from a database?
Hide Servlet Response from appearing in Google Search