JSP – Checking if a file exists. Posted on 2018-01-04 這個 sample code 滿簡單的: ServletContext app = getServletContext(); String path = app.getRealPath("/"); File theFile = new File(path + "/images/your-file.jpg"); out.print("File Exists: " + theFile.exists() + "<br/>");