0

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?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Simo
  • 1
  • 1

1 Answers1

1

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().
Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140