You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2010/02/03 14:42:12 UTC

svn commit: r906041 - /felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java

Author: fmeschbe
Date: Wed Feb  3 13:42:11 2010
New Revision: 906041

URL: http://svn.apache.org/viewvc?rev=906041&view=rev
Log:
FELIX-2030 Calculate the context path from the actual context path and the
servlet path of the "servlet" registered in the container.

Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java?rev=906041&r1=906040&r2=906041&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRequest.java Wed Feb  3 13:42:11 2010
@@ -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) {