You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "David Hay (JIRA)" <ji...@apache.org> on 2011/01/11 22:12:47 UTC

[jira] Created: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
---------------------------------------------------------------------

                 Key: FELIX-2774
                 URL: https://issues.apache.org/jira/browse/FELIX-2774
             Project: Felix
          Issue Type: Bug
          Components: HTTP Service
    Affects Versions: http-2.0.4
            Reporter: David Hay


I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.

I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)

    <servlet>
        <servlet-name>osgi-servlet-bridge</servlet-name>
        <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>osgi-servlet-bridge</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>


I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:

RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
rd.forward(request, response);

This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980548#action_12980548 ] 

Felix Meschberger commented on FELIX-2774:
------------------------------------------

Actually, neither forward nor include are really properly implemented in that both do not set the required request attributes.

In addition the forward method to overwrite the getRequestURI method with the forward target looks wrong to me, too, because these methods should always return the same value. It is the request attributes baring the new path strings.

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>            Assignee: Felix Meschberger
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-2774:
-------------------------------------

    Attachment: FELIX-1962-listeners.patch

Simple patch against the HTTP Base module:

  - Removes the Request Wrapper overwriting getRequestURI method from the game
  - Adds a ServletHandler.handleInclude method which calls the Servlet's service method
      without the ServletHandlerRequestWrapper (on the grounds that the path related getter
      methods must return the same values)
  - Adds a resetBuffer() call to the forward method

What's still missing is the management of the request attributes mandated by the Servlet API specification

Shall we go this route ? Any takers to hack on the request attribute provisioning ?

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>            Assignee: Felix Meschberger
>         Attachments: FELIX-1962-listeners.patch
>
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned FELIX-2774:
----------------------------------------

    Assignee:     (was: Felix Meschberger)

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>         Attachments: FELIX-1962-listeners.patch
>
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-2774:
-------------------------------------

    Attachment:     (was: FELIX-1962-listeners.patch)

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated FELIX-2774:
-------------------------------------

    Attachment: FELIX-2774-simple.patch

Attaching correct patch this time

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>         Attachments: FELIX-2774-simple.patch
>
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12980548#action_12980548 ] 

Felix Meschberger edited comment on FELIX-2774 at 1/11/11 11:30 PM:
--------------------------------------------------------------------

Actually, neither forward nor include are really properly implemented in that both do not set the required request attributes.

In addition the forward method to overwrite the getRequestURI method with the forward target looks wrong to me, too, because these methods should always return the same value. It is the request attributes baring the new path strings.

In addtion on forward or include the HttpContext.handleSecurity method is probably not to be called any more ...

      was (Author: fmeschbe):
    Actually, neither forward nor include are really properly implemented in that both do not set the required request attributes.

In addition the forward method to overwrite the getRequestURI method with the forward target looks wrong to me, too, because these methods should always return the same value. It is the request attributes baring the new path strings.
  
> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>            Assignee: Felix Meschberger
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (FELIX-2774) HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-2774?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger reassigned FELIX-2774:
----------------------------------------

    Assignee: Felix Meschberger

> HTTP Servlet RequestDispatcher 'forward' has invalid request pathInfo
> ---------------------------------------------------------------------
>
>                 Key: FELIX-2774
>                 URL: https://issues.apache.org/jira/browse/FELIX-2774
>             Project: Felix
>          Issue Type: Bug
>          Components: HTTP Service
>    Affects Versions: http-2.0.4
>            Reporter: David Hay
>            Assignee: Felix Meschberger
>
> I'm trying to have one servlet forward to another servlet.  However, the forwarding doesn't seem to work.
> I've set up the proxy servlet in my web.xml as follows (and this is the only servlet...no filters defined)
>     <servlet>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>osgi-servlet-bridge</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> I then have two bundles, each registers a servlet under a different path (e.g. bundle A registers under alias '/a' and bundle B registers under alias '/b') using the whiteboard pattern.  The implementation of servlet A ends up doing this:
> RequestDispatcher rd = request.getRequestDispatcher("/b/some/path");
> rd.forward(request, response);
> This finds the ServletHandler for servlet B just fine, but gets hung up in the 'handle' method. I think this is due to the implementation of the internal RequestWrapper class in the ServletPipeline class.  This implementation overrides the getRequestURI method with the passed in value.  However, ServletHandler.handle passed the result of HttpServletRequest.getPathInfo() to the 'matches' method as a final check to make sure that the servlet should be invoked.  Since the RequestWrapper class does not override getPathInfo, it returns the value from the original request....which is '/a' in my example.
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.