Tomcat (v7.0.21 at least) returns the absolute file path where a folder "would have been" for servletContext.getRealPath("/someFolderThatDoesNotExist/"). Jetty (v7.3.0) returns null in such cases (so it only returns resources, or folder, that are actually available in the directory where the expanded WAR is); see also http://dev.eclipse.org/mhonarc/lists/jetty-dev/msg00773.html The Servlet Spec doesn't clearly say either way - what Jetty does seems more logical to me... and is also the assumption made e.g. in BIRT; for more background see https://bugs.eclipse.org/bugs/show_bug.cgi?id=357315 & http://mifosforge.jira.com/browse/MIFOS-5118.
My reading of the Servlet specification and Javadoc is that there is no requirement for the path to exist, just for the container to map the virtual path to a physical if such a mapping is possible. I'll raise a bug against the Servlet specification to get this clarified but my inclination is to resolve this as invalid.
See http://java.net/jira/browse/SERVLET_SPEC-11
The behavior has never changed, has always been consistent, and nowhere in the specification does it say the path needs to exist. Unlike for getResource, where the behavior for a non existent resource is clearly defined as being different. So why is there any doubt about this ? If you didn't realize this could be used to create a file in the filesystem, then it would still be nice to not assume by default that the specification must be stupid because a user says so. And that, even if there wasn't any good reason at all, the change would *again* break plenty of existing applications.
Remy, I agree with you completely that Tomcat's behaviour is correct but having read the spec quite carefully I couldn't find anything explicit that states that the resource doesn't have to exist and there was enough ambiguity that I can understand how someone may have reached a different conclusion. I just think a few words of clarification in the spec wouldn't hurt. If you wanted to add you views to SPEC-11 that would be great.
The EG is in agreement (including the Jetty rep) that the current behaviour is correct.