This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion 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.
I agree. Here's the link:
subject: PDF display in JSP
jQuery in Action, 3rd edition