GWTShellServet's emulated getResource() implementation was not handling files on the public path correctly.

Patch by: mmendez
Review by: scottb, jat, tobyr (desk check)


git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.4@1391 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java b/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java
index 10151a1..344348e 100644
--- a/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java
+++ b/dev/core/src/com/google/gwt/dev/shell/HostedModeServletContextProxy.java
@@ -148,13 +148,17 @@
    * @see javax.servlet.ServletContext#getResource(java.lang.String)
    */
   public URL getResource(String path) throws MalformedURLException {
-    if (path.startsWith("/")) {
-      path = path.substring(1);
+    String moduleContext = "/" + moduleDef.getName() + "/";
+    if (!path.startsWith(moduleContext)) {
+      // This path is in a different context; just return null
+      return null;
     }
-
-    URL url = moduleDef.findPublicFile(path);
+    
+    // Try to get the resource from the application's public path
+    URL url = moduleDef.findPublicFile(path.substring(moduleContext.length()));
     if (url == null) {
-      File requestedFile = new File(outputDir, path);
+      // Otherwise try the path but rooted in the output directory
+      File requestedFile = new File(outputDir, path.substring(1));
       if (requestedFile.exists()) {
         url = requestedFile.toURL();
       }