When writing a JSP file, how can I get the current directory of this file at runtime (to be able to iterate the directory and list its contents)?
As of Version 2.1 of the Java Servlet API use:
File jsp = new File(request.getSession().getServletContext().getRealPath(request.getServletPath())); File dir = jsp.getParentFile(); File[] list = dir.listFiles();