Hi Mark,

Mark Derricutt schrieb:
> Hi Bertrand,
> 
> Looks like the paxweb ticket we raised (
> http://issues.ops4j.org/jira/browse/PAXWEB-108) has been closed "wont-fix"
> as its actually now doing the correct thing according to the Servlet 2.4
> spec, section 11.2 reads:
> 
> "A string containing only the '/' character indicates the "default" servlet
> of
> the application. In this case the servlet path is the request URI minus the
> context
> path and the path info is null."
> 
> I've not yet tried it, but I'm wondering if the sling servlet gets mounted
> as '/*' then we'd see the path info being restored.  Shall I go raise this
> as a Sling issue?

After digging around a bit (and also reading a post by Alin Dereghiciu
on the OSGi dev list [1]), I think we should fix something in the Sling
engine ...

How about this approach (all in the engine module) :

* The SlingMainServlet is always registered with the HttpService with
the servlet path "/". This cannot be configurable.
* The SlingHttpServletRequestImpl, which is instantiated by the
SlingMainServlet to provide the SlingHttpServletRequest interface, is
modified to overwrite the getServletPath() and getPathInfo() methods as
follows (see also Section SRV.4.4 in Servlet API 2.4 spec) :
   * getServletPath() always returns ""
   * getPathInfo() always returns the getServletPath()+getPathInfo()
        called on the servlet container (or HttpService provided)
        HttpServletRequest object

This should reproduce the behaviour of registering the SlingMainServlet
as "/*" no matter how the HttpService would handle this. See the
proposed patch attached below.

WDYT ?

BTW: We had a similar issue running a modified Sling Web App in Weblogic
9, where getPathInfo() return null even though the request URL was not
addressed at the Servlet itself. This may be related.


Regards
Felix

[1] http://www.mail-archive.com/[EMAIL PROTECTED]/msg00440.html


Proposed patch:

Index:
/usr/src/sling/head/engine/src/main/java/org/apache/sling/engine/impl/SlingHttpServletRequestImpl.java
===================================================================
---
/usr/src/sling/head/engine/src/main/java/org/apache/sling/engine/impl/SlingHttpServletRequestImpl.java
(revision 713054)
+++
/usr/src/sling/head/engine/src/main/java/org/apache/sling/engine/impl/SlingHttpServletRequestImpl.java
(working copy)
@@ -59,6 +59,7 @@
         SlingHttpServletRequest {

     private final RequestData requestData;
+    private final String pathInfo;
     private String responseContentType;

     public SlingHttpServletRequestImpl(RequestData requestData,
@@ -65,6 +66,13 @@
             HttpServletRequest servletRequest) {
         super(servletRequest);
         this.requestData = requestData;
+
+        // prepare the pathInfo property
+        String pathInfo = servletRequest.getServletPath();
+        if (servletRequest.getPathInfo() != null) {
+            pathInfo = pathInfo.concat(servletRequest.getPathInfo());
+        }
+        this.pathInfo = pathInfo;
     }

     /**
@@ -275,6 +283,25 @@
     }

     /**
+     * Always returns the empty string since the actual servlet
registered with
+     * the servlet container (the HttpService actually) is registered as if
+     * the servlet path is "/*".
+     */
+    @Override
+    public String getServletPath() {
+        return "";
+    }
+
+    /**
+     * Returns the part of the request URL without the leading servlet
context
+     * path.
+     */
+    @Override
+    public String getPathInfo() {
+        return pathInfo;
+    }
+
+    /**
      * A <code>UserPrincipal</code> ...
      */
     private static class UserPrincipal implements Principal, Serializable {

> 
> Mark
> 
> 
> On Wed, Nov 12, 2008 at 10:14 AM, Bertrand Delacretaz <
> [EMAIL PROTECTED]> wrote:
> 
>> On Tue, Nov 11, 2008 at 9:34 PM, Mark Derricutt <[EMAIL PROTECTED]> wrote:
>>> ....We've raised a ticket over at OPS4J and
>>> the issue is scheduled for a 0.5.2 release:..
>> Cool, thanks for the info!
>> -Bertrand
>>
> 
> 
> 

Reply via email to