Images, databases and jsf - how to make it work?
I am trying to get my head around how to do this - I hope somebody can tell me how, please.
I have a database table in which I want to store image files (like .png, jpg, etc) - something like:
table images(
key int,
blob bigpicture
)
I want to extract pictures from the table and display them in a jsf page; I know how to go about database tables etc in general in Java EE, but I am not sure about images - is there a place I can read more about it? Or is it just really simple?
Another things is - how about uploading pictures, which is the other, important part of this?
Thanks a lot!
Doesn anybody know when Mojarra 2.2 is due out?
Uploading an image into the database is not such a big deal. However, extracting it and displaying it in the database seems to be more of a problem. I managed to extract an image from the database using the posting at http://balusc.blogspot.de/2007/04/imageservlet.html.
However, that only works when I manually enter the Image URL in the address line of the browser, e.g. http://localhost:8080/myapp/image?id=aeb3e5... Here, the servlet is being called and the image is displayed stand-alone in the browser.
If, however, I try to include the image in a JSF site (e.g. . However, I would like to have the servlet being called and thus make JSF to return the JSF site along with the image.
What could the problem be? Is my understanding not correct in the sense that the server can render a JSF site and include the binary stream in it?





I wouldn't say that it is really hard, but there is some stuff you have to do. If you have set the entity and dao to insert images to db then its cool. The only thing you have to do is create a servlet which will catch the request params and search the image in the db and show it using stream.
You can find a good example here:
JSF - Displaying images from database in JSF