3

Is possible to check in JSTL if a file exists (exactly an image):
Simply issue of viewing profile image. If is in the folder with images profile image show the profile image, if not show default image.

This is a pseudo code:

if file img/1.jpg exist:
<img src="img/1.jpg" />
if file img/1.jpg doesn't exist
<img src="img/default_image.jpg" />


Note: I am prohibited from using scriptlets. I have to use JSTL in JSP.

informatik01
  • 16,038
  • 10
  • 74
  • 104
user1097772
  • 3,499
  • 15
  • 59
  • 95
  • 1
    Been answered here: http://stackoverflow.com/questions/2624657/how-can-you-check-if-a-file-exists-before-including-importing-it-in-jsp – vector Jan 14 '13 at 21:25
  • @vector I saw that but I don't see the answer in it. It doesn't help me so it's the reason why I asked. And I also think that it's different problem, I don't want to include anything. So is it possible or not? – user1097772 Jan 14 '13 at 21:34
  • @vector Ok, so it's imposible to do it this way. Thanks. I'll try to do it somehow in Servlet. – user1097772 Jan 14 '13 at 21:39
  • @vector Can you copy your last comment as an answer, I'll accept it as answer cause its exact answer to the question. Thanks – user1097772 Jan 14 '13 at 21:42

1 Answers1

1

Not if you have to use straight JSTL, you could do it in a scriptlet, but you'll be advised that it's not recommended

vector
  • 7,334
  • 8
  • 52
  • 80