webtier@glassfish.java.net

Re: Images, databases and jsf - how to make it work?

From: Jason Lee <jason.d.lee_at_oracle.com>
Date: Thu, 09 Feb 2012 10:18:19 -0600

On 2/9/12 9:43 AM, forums_at_java.net wrote:
> 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?
There are probably several ways you can do it. The easiest might be a
simple Servlet. You construct URLs that point to this Servlet, which
reads the data from the database and returns it to the user, setting all
the proper headers, etc. If you want a more JSF-ish way to do it, this
old blog post of mine might help:
http://blogs.steeplesoft.com/2010/05/putting-facelets-in-a-jar/

That post notes that it doesn't directly address database access, but,
hopefully, there's enough there to get you going if you choose that
route. A Servlet is probably simpler. :)
> Another things is - how about uploading pictures, which is the other,
> important part of this?
Currently, JSF doesn't have file upload support built in. JSF 2.2,
which is due out sometime "soon" will fix that. I'm guessing you need
it now, though. :) There are several blog entries around the web
describing how to roll your own solution, but if you're not opposed to a
third party JSF component library, both RichFaces and ICEfaces have
great file upload components that should meet your needs.

-- 
Jason Lee
Senior Member of Technical Staff
GlassFish Team
Oracle Corporation
Phone +1 405-216-3193
Blog http://blogs.steeplesoft.com