Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1899

HttpServletRequest.getHttpServletMapping() return incorrect value after forwarded by <error-page/> definition

    XMLWordPrintable

Details

    Description

      Consider the following web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      	xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
      	version="4.0">
      
      	<servlet>
      		<servlet-name>ErrorHandler</servlet-name>
      		<servlet-class>ErrorHandler</servlet-class>
      	</servlet>
      	<servlet-mapping>
      		<servlet-name>ErrorHandler</servlet-name>
      		<url-pattern>/ErrorHandler</url-pattern>
      	</servlet-mapping>
      
      	<error-page>
      		<exception-type>java.lang.Exception</exception-type>
      		<location>/ErrorHandler</location>
      	</error-page>
      
      </web-app>
      

      The `ErrorHandler` servlet received an incorrect value when calling `HttpServletRequest.getHttpServletMapping()` after forwarded by <error-page/> definition in web.xml.
      It is expected to return the servlet mapping info of `ErrorHandler` servlet but it incorrectly returned the servlet mapping info which the original error happened before forwarding.

      Checked with Tomcat 9.0.46 and Jetty 10.0.3 which they correctly returned servlet mapping info after forwarded by <error-page/>, so suspected this should be a bug in Undertow.

      Attached sample war for reproduce this issue ( UNDERTOW-1899.war ).
      Accessing http://localhost:8080/UNDERTOW-1899/ will trigger exception and forward to `ErrorHandler` servlet, which just print the servlet mapping info.
      Expecting to print `servletName: ErrorHandler, pattern: /ErrorHandler, mappingMatch: EXACT, matchValue: ErrorHandler` in the server log but actually got `servletName: jsp, pattern: *.jsp, mappingMatch: EXTENSION, matchValue: index`

      Attachments

        Activity

          People

            rhn-cservice-bbaranow Bartosz Baranowski
            sammyhk Sammy Chu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: