tags:

views:

28

answers:

1

I'm using the h:graphicImage tag in JSF. Is there a way to show a blank image (i.e. blank.jpg) if there is a broken or not found image?

+1  A: 

There are two ways:

  • client side - with javascript, see here
  • server side (less preferable) make an ImageServlet which takes an image url, loads it and sees if it exists. If it exists, it is streamed to to client. If not - the blank.jpg is streamed to the client. Verification can be done via new File(fullPathToImage).exists(), or, if the image is not on your server, using URL.openConnection().
Bozho