user1097772
user1097772

Reputation: 3529

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.

Upvotes: 3

Views: 3300

Answers (1)

vector
vector

Reputation: 7566

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

Upvotes: 1

Related Questions