IBM Support

PI27348: AN EMPTY STRING "" AS THE URL PATTERN OF A SERVLET CAUSES AN UNWANTED 302 REDIRECTION AND AN EXCEPTION

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • Servlet 3.0 Specifications state, in section 12.2, the
    following:
    .
    The empty string ("") is a special URL pattern that exactly
    maps to the application's context root, that is, requests
    of the form
    http://host:port/<contextroot>/.
    In this case the path info is &#146;/&#146; and the servlet path and
    context path is
    empty string ("").
    Specifying an empty string as the URL pattern of a servlet
    causes a 302 redirection from http://host:port/<contextroot>
    to http://host:port/<contextroot>/ and the servlet is never
    invoked. Once in  http://host:port/<contextroot>/ a 404 error
    page is displayed if there is no other servlet with a URL
    pattern that matches the relative path '/'.
    .
    An example of a servlet mapping that causes the issue:
    .
       <servlet>
            <servlet-name>test-servlet</servlet-name>
            <servlet-class>com.example.TestServlet</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>test-servlet</servlet-name>
            <url-pattern></url-pattern>
        </servlet-mapping>
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:  All users of IBM WebSphere Application      *
    *                  Server Liberty Profile version 8.5.5        *
    ****************************************************************
    * PROBLEM DESCRIPTION: An empty string ("") as the URL pattern *
    *                      of a servlet causes an unwanted 302     *
    *                      redirection and a                       *
    *                      java.lang.StringIndexOutOfBoundsExcepti *
    *                      on occurs.                              *
    ****************************************************************
    * RECOMMENDATION:                                              *
    ****************************************************************
    The Servlet 3.0 Specification, in section 12.2, states the
    following:
    
    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/<contextroot>/.
    In this case the
    path info is ?/? and the servlet path and context path is
    empty
    string ("").
    
    However when using the Liberty Profile, specifying
    an empty string ("") as the URL pattern of a servlet causes a
    302 redirection from http://host:port/<contextroot> to
    http://host:port/<contextroot>/ and the servlet is never
    invoked. Once in http://host:port/<contextroot>/ a 404 error
    page is displayed if there is no other servlet with a URL
    pattern that matches the relative path '/'.
    
    Also, the following
    exception will be thrown:
    
    com.ibm.ws.webcontainer.webapp.WebApp
    E jspAwareCreateServletWrapper SRVE0271E: Uncaught init()
    exception created by servlet [SERVLET_NAME] in application
    [APPLICATION_NAME]: java.lang.StringIndexOutOfBoundsException
    
    at java.lang.String.charAt(String.java:555)
    	at
    com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.j
    ava:1648)
    	at
    com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.j
    ava:1622)
    	at
    com.ibm.ws.webcontainer.webapp.WebApp.jspAwareCreateServletWrapp
    er(WebApp.java:1405)
    	at
    com.ibm.ws.webcontainer.webapp.WebApp.createServletWrappers(WebA
    pp.java:1351)
    	[...]
    
    The following is an example of a servlet
    mapping that causes the issue:
    
    &#160;&#160;  <servlet>
    &#160;&#160; &#160;&#160;&#160; &#160;<servlet-
    name>test-servlet</servlet-name>
    &#160;&#160; &#160;&#160;&#160; &#160;<servlet-
    class>com.example.TestServlet</servlet-class>
    &#160;&#160; &#160;</servlet>
    &#160;&#160;
    &#160;<servlet-mapping>
    &#160;&#160; &#160;&#160;&#160; &#160;<servlet-name>test-servlet</servlet-
    name>
    &#160;&#160; &#160;&#160;&#160; &#160;<url-pattern></url-pattern>
    &#160;&#160; &#160;</servlet-
    mapping>
    

Problem conclusion

  • The WebContainer code has been modified to properly map an empty
    string ("") URL pattern to the application's context root.
    
    The
    fix for this APAR is currently targeted for inclusion in fix
    pack 8.5.5.4.  Please refer to the Recommended Updates page for
    delivery information:
    http://www.ibm.com/support/docview.wss?rs=180&uid=swg27004980
    

Temporary fix

Comments

APAR Information

  • APAR number

    PI27348

  • Reported component name

    WAS LIBERTY COR

  • Reported component ID

    5725L2900

  • Reported release

    855

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    NoHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2014-10-10

  • Closed date

    2014-10-16

  • Last modified date

    2014-10-16

  • APAR is sysrouted FROM one or more of the following:

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    WAS LIBERTY COR

  • Fixed component ID

    5725L2900

Applicable component levels

  • R855 PSY

       UP

[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSD28V","label":"WebSphere Application Server Liberty Core"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"855","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
28 April 2022