I'm working on a project where I want to store gif or jpg images into a MySQL database using the BLOB data type. That part is easy. I got that figured out. What I need to know is how do I store and retrieve the image to and from the database using which Java data types (ImageIcon maybe)? Also, ordinarily to display an image in HTML you use the <img src="..."> tag. Its' src attribute requires a string pointing to an image file in a directory structure. But in this case, I'm not retrieving the file from a directory tree, I'm getting it straight from a database. So in the JSP page how do I display an image retrieved from a class that got the image from the database? I need to see an example of how this is done.
Originally posted by Bear Bibeault: The src attribute of your img tag will address a servlet that will read the data from the db, set the content headers as appropriate, and stream the data to the response.
Do you have some sample code of a servlet and sends back a response for an image? I need to see an example of how it's done.