Tim Holloway wrote:According to the J2EE standard, a deployed webapp is a WAR (or EAR) file, both of which are in JAR (ZIP) format.
The getRealPath() method is therefore treacherous, since there's no actual filesystem path to resources that are stored within the WAR, only a path to the WAR itself.
While Tomcat often does "explode" WARs into actual directories and files, it's not a good idea to create webapps that depend on this. You are better off putting your script in an external directory and directing the webapp to that location. If you prefer, you can make the actual filesystem path of that script or its directory be a configuration option (in web.xml) or a JNDI object.