I referred to this Q&A but I'm not able to do what I want.
I want to display an image if the path of this image exist and something else if the image path doesn't exist. So I did this :
<% String filePath = photoPath + nom.toLowerCase().replace(' ', '_') +"_"+prenom.toLowerCase().replace(' ', '_') + ".jpg";
Path path = Paths.get(filePath);
if(Files.exists(path)) {
%>
<img name="" src="<%=filePath %>" width="96" height="120" alt=" Photographie de <%=prenom%> <%=nom%>">
<% }
else { %>
<%=filePath %>
<img name="" src="<%=filePath %>" width="96" height="120" alt=" Photographie de <%=prenom%> <%=nom%>">
<%
}
%>
Here I try the same thing in the if
and else
except that I show the path and the image in the else
. My output is the else
statement so my image shouldn't be displayed but the image is displayed.
Any idea ?