File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Display a database BLOB in a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Display a database BLOB in a jsp" Watch "Display a database BLOB in a jsp" New topic
Author

Display a database BLOB in a jsp

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 382
the IMG tag takes a src path to an image to display it. But if you are getting the image from a database (or file system) it is not part of the web app. So how would you set the src param? Or is there another way to display it, since it is a stream of bytes when you get it from the database?
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1016
The standard approach is to have the src tag of the image point at a Servlet which is part of the webapp.
eg
<img src="/myWebApp/imageServlet?imageid=42"/>

That servlet is then responsible for loading the image, and sending it out via the ServletOutputStream.
Dave Wingate
Ranch Hand

Joined: Mar 26, 2002
Posts: 262
Here's a shell to get you started:



Fun programming etcetera!
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 382
This is a big help. Thanks guys
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display a database BLOB in a jsp
 
Similar Threads
Displaying Image in JSP
Displaying image with data type as longblob
Storing, retrieving, displaying images
Registration page with 'Image Security Code'
Displaying byte array as image using javascript