Search code examples
jspjstlfile-exists

Checking if a file exists using JSTL in a JSP page


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.


Solution

  • 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