.jsp help... "error" .jpg possible?

Homerboy

Lifer
Mar 1, 2000
30,890
5,001
126
I have a site created in .jsp but I cant think of a way to creat a "error" or "default" .jpg for the HTML to display if the called .jpg is not found.

so if the .jsp code called to insert XYZ.jpg into the HTML, but XYZ.jpg was not found, rather than display the stupid broen missing image icon in IE etc, it woudl default and insert ABC.jpg in its place?
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
I think this would have to be server side. All images would have to go through some jsp page, which would load the real image and spit it out. Another possibility would be a really tricky file not found custom page that somehow knew to spit out an image if it's an image but a standard file not found message otherwise.
 

znaps

Senior member
Jan 15, 2004
414
0
0
I would have guessed you could do this with Apache, but I may be wrong.

One other uglier way to do it would be to try and load the image in your JSP using ImageIcon(URL), and if that if that evaluates as null, then generate a link to your ABC.jpg instead. You could create a static utility class to do this for all image links.