Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-74114 Make Liferay compatible with version 2.0 tests in the Portlet 3.0 TCK
  3. LPS-74936

Portlet 3.0 TCK: Correctly handle servlet_path and path_info in PortletRequestDispatcherImpl



      Test result

      PortletRequestDispatcherImpl sets what should be servletPath to pathInfo. This causes 80 failures in Portlet TCK 3.0 tests.


      According to Portlet Specification 25.1.2, 25.5.1 and 25.6.1, when dispatching a request to a servlet/jsp, the HttpServletRequest methods getPathInfo(), getPathTranslated(), getQueryString(), getRequestURI() and getServletPath() (invoked in the target servlet) must return the path and query string information used to obtain the PortletRequestDispatcher object; several request attributes, like javax.servlet.include.path_info, must be set to the request and must be equal to the return values of the HttpServletRequest methods, like getPathInfo().

      There are a lot of TCK test cases testing this requirement for include/forward towards servlet/jsp. 80 test cases failed due to the mismatch of expected values or attribute values against method return values.

      Take a servlet mapping of the servlet used in a tck test case as example:


      The path used to obtain the PortletRequestDispatcher in the test case is

      According to the Servlet Spec (here we used Servlet Spec 3.1), chapter 12,

      • A string beginning with a ‘ / ’ character and ending with a ‘ /* ’ suffix is used for path mapping.
      • A string beginning with a ‘ *. ’ prefix is used as an extension mapping.
      • The empty string ("") is a special URL pattern that exactly maps to the application's context root, i.e., requests of the form http://host:port/<context-root>/. In this case the path info is ’ / ’ and the servlet path and context path is empty string (““).
      • 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.
      • All other strings are used for exact matches only.

      For the servlet above, it’s a exact match, so the servlet path should be /DispatcherTests_SPEC2_19_IncludeServletAction_servlet and the path info should be null.

      However, in PortletRequestDispatcherImpl, when parsing the path elements (PortletRequestDispatcherImpl.java#L165), we only set the servlet path when the url-pattern in the mapping ends with “/*”, and for other cases we set the dispatch target path as path_info. As a result, the path_info is set as /DispatcherTests_SPEC2_19_IncludeServletAction_servlet and servlet_path is null, which is wrong.

      For example, according to Servlet Spec chapter 3.5, for path like “WEB-INF/path/to/view.jsp”, the servlet_path should be this path itself, and path_info should be null. While in our PortletRequestDispatcherImpl, the servlet_path is set to null and path_info is set to this path.




            brian.chan Brian Chan
            dante.wang Dante Wang
            Recent user:
            Csaba Turcsan
            Participants of an Issue:
            0 Vote for this issue
            0 Start watching this issue


              Days since last comment:
              3 years, 33 weeks, 3 days ago


                Version Package
                7.0.0 DXP FP33
                7.0.0 DXP SP7
                7.0.5 CE GA6