tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r609655 - /incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
Date Mon, 07 Jan 2008 16:06:01 GMT
Author: antelder
Date: Mon Jan  7 08:06:00 2008
New Revision: 609655

URL: http://svn.apache.org/viewvc?rev=609655&view=rev
Log:
Another contextpath fiddle to cope with multiple root elements

Modified:
    incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java

Modified: incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java?rev=609655&r1=609654&r2=609655&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
(original)
+++ incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
Mon Jan  7 08:06:00 2008
@@ -20,6 +20,7 @@
 package org.apache.tuscany.sca.host.webapp;
 
 import java.io.IOException;
+import java.util.StringTokenizer;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.Servlet;
@@ -69,18 +70,34 @@
                 if (path.length() == 0) {
                     path = super.getPathInfo();
                 }
-                // TODO: another context path hack, shouldn't hardcode this "tuscany" string
-                if (servletPath.startsWith("/tuscany/")) {
-                    path = path.substring(servletPath.length()-8);
-                } else {
-                    path = path.substring(servletPath.length());
-                }
+
+                // TODO: another context path hack, revisit when context path is sorted out
+                path = fiddlePath(path, servletPath);
+
                 return path;
             }
         };
         return requestWrapper;
     }
-    
+
+    /**
+     * Remove any path suffix thats part of the servlet context path
+     */
+    protected String fiddlePath(String path, String servletPath) {
+        StringTokenizer st = new StringTokenizer(path, "/");
+        String root = "";
+        while (st.hasMoreTokens()){
+                String s = st.nextToken();
+                if (servletPath.endsWith((root + "/" + s))) {
+                        root += "/" + s;
+                } else {
+                        break;
+                }
+        }
+        String fiddlePath = path.substring(root.length());
+        return fiddlePath;
+    }
+
     public void forward(ServletRequest request, ServletResponse response) throws ServletException,
IOException {
         servlet.service(createRequestWrapper(request), response);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message