private boolean isFileSameCase(final Path file, String normalizeFile) throws IOException {
        String canonicalName = file.toRealPath().toString();
        return canonicalName.equals(normalizeFile);
    }
private boolean isFileSameCase ( final Path file , String normalizeFile ) throws IOException { String canonicalName = file . toRealPath ( ) . toString ( ) ; return canonicalName . equals ( normalizeFile ) ; }
Security check for case insensitive file systems.
We make sure the case of the filename matches the case of the request.
This is only a check for case sensitivity, not for non canonical . and ../ which are allowed.

For example:
file.getName() == "page.jsp" && file.getCanonicalFile().getName() == "page.jsp" should return true
file.getName() == "page.jsp" && file.getCanonicalFile().getName() == "page.JSP" should return false
file.getName() == "./page.jsp" && file.getCanonicalFile().getName() == "page.jsp" should return true