getServletPath() output JSP name instead of action name when a request is forwarded inside Servlet application in EAP 7

Solution Unverified - Updated -

Issue

We are trying to migrate our application from JBoss EAP 6.x to JBoss EAP 7.x. We found that EAP 6.x and EAP 7.x return different results of HttpServletRequest.getServletPath() (and also getRequestURI() and getRequestURL()](https://docs.oracle.com/javaee/7/api/javax/servlet/http/HttpServletRequest.html#getRequestURL--)) after invoking RequestDispatcher.forward(). This behavior change causes an issue with our application using Struts and Siteminder framework.

  • In JBoss EAP 6.4:

    getServletPath() = /example.action 
    getRequestURI() = /myapp/example.action
    
  • In JBoss EAP 7.x:

    getServletPath() = /jsp/forward/example.jsp 
    getRequestURI() = /myapp/jsp/forward/example.jsp 
    

Also, you can observe the different behavior with the following code in the servlet application without using Struts framework:

System.out.println("getServletPath() before forward = " + request.getServletPath());
System.out.println("getRequestURI() before forward = " + request.getRequestURI());
System.out.println("getRequestURL() before forward = " + request.getRequestURL());
request.getRequestDispatcher("/jsp/forward/example.jsp").forward(request, response);
System.out.println("getServletPath() after forward = " + request.getServletPath());
System.out.println("getRequestURI() after forward = " + request.getRequestURI());
System.out.println("getRequestURL() after forward = " + request.getRequestURL());
  • In JBoss EAP 6.4:

    getServletPath() before forward = /example
    getRequestURI() before forward = /myapp/example
    getRequestURL() before forward = http://<hostname>:<port>/myapp/example
    getServletPath() after forward = /example 
    getRequestURI() after forward = /myapp/example
    getRequestURL() after forward = http://<hostname>:<port>/myapp/example
    
  • In JBoss EAP 7.x:

    getServletPath() before forward = /example 
    getRequestURI() before forward = /myapp/example
    getRequestURL() before forward = http://<hostname>:<port>/myapp/example
    getServletPath() after forward = /jsp/forward/example.jsp 
    getRequestURI() after forward = /myapp/jsp/forward/example.jsp 
    getRequestURL() after forward = http://<hostname>:<port>/myapp/jsp/forward/example.jsp
    

Is it possible to make JBoss EAP 7 behave the same as JBoss EAP 6?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content