How can you check if a file exists before including/importing it in JSP?
Posted
by codeninja
on Stack Overflow
See other posts from Stack Overflow
or by codeninja
Published on 2010-04-12T19:09:55Z
Indexed on
2010/04/12
19:13 UTC
Read the original article
Hit count: 155
Assuming that requestScope.importMe is expecting a path to a jsp file
<c:choose>
<c:when test="${!empty requestScope.importMe && fileExists(requestScope.importMe) }">
<c:import url="${requestScope.importMe}" />
...
How can I check if the file exists before trying to include it so that an error is not thrown?
I'd like to avoid using inline Java. Something using one of the JSTL tags is the preferred approach.
© Stack Overflow or respective owner