FELIX-2030 Calculate the context path from the actual context path and the
servlet path of the "servlet" registered in the container.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@906041 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java
index 6121b78..1e3c10e 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java
@@ -25,6 +25,7 @@
     extends HttpServletRequestWrapper
 {
     private final String alias;
+    private String contextPath;
     private String pathInfo;
     private boolean pathInfoCalculated = false;
 
@@ -46,6 +47,28 @@
     }
 
     @Override
+    public String getContextPath()
+    {
+        /*
+         * FELIX-2030 Calculate the context path for the Http Service
+         * registered servlets from the container context and servlet paths
+         */
+        if (contextPath == null) {
+            final String context = super.getContextPath();
+            final String servlet = super.getServletPath();
+            if (context.length() == 0) {
+                contextPath = servlet;
+            } else if (servlet.length() == 0) {
+                contextPath = context;
+            } else {
+                contextPath = context + servlet;
+            }
+        }
+
+        return contextPath;
+    }
+
+    @Override
     public String getPathInfo()
     {
         if (!this.pathInfoCalculated) {